diff mbox series

[02/19] lirc: rc_dev_get_from_fd(): fix file leak

Message ID 20240607015957.2372428-2-viro@zeniv.linux.org.uk (mailing list archive)
State New
Headers show
Series [01/19] powerpc: fix a file leak in kvm_vcpu_ioctl_enable_cap() | expand

Commit Message

Al Viro June 7, 2024, 1:59 a.m. UTC
missing fdput() on a failure exit

Fixes: 6a9d552483d50 "media: rc: bpf attach/detach requires write permission" # v6.9
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
 drivers/media/rc/lirc_dev.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Christian Brauner June 7, 2024, 3:17 p.m. UTC | #1
On Fri, Jun 07, 2024 at 02:59:40AM +0100, Al Viro wrote:
> missing fdput() on a failure exit
> 
> Fixes: 6a9d552483d50 "media: rc: bpf attach/detach requires write permission" # v6.9
> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
> ---

Reviewed-by: Christian Brauner <brauner@kernel.org>
diff mbox series

Patch

diff --git a/drivers/media/rc/lirc_dev.c b/drivers/media/rc/lirc_dev.c
index 52aea4167718..717c441b4a86 100644
--- a/drivers/media/rc/lirc_dev.c
+++ b/drivers/media/rc/lirc_dev.c
@@ -828,8 +828,10 @@  struct rc_dev *rc_dev_get_from_fd(int fd, bool write)
 		return ERR_PTR(-EINVAL);
 	}
 
-	if (write && !(f.file->f_mode & FMODE_WRITE))
+	if (write && !(f.file->f_mode & FMODE_WRITE)) {
+		fdput(f);
 		return ERR_PTR(-EPERM);
+	}
 
 	fh = f.file->private_data;
 	dev = fh->rc;