Commit 31829d5e authored by Al Viro's avatar Al Viro Committed by ZhangPeng
Browse files

lirc: rc_dev_get_from_fd(): fix file leak

stable inclusion
from stable-v6.6.44
commit f4c6ebb053cc94b6ee2e2051a526cd6bd2ae53d4
bugzilla: https://gitee.com/openeuler/kernel/issues/IAHMJO

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=f4c6ebb053cc94b6ee2e2051a526cd6bd2ae53d4



--------------------------------

[ Upstream commit bba1f6758a9ec90c1adac5dcf78f8a15f1bad65b ]

missing fdput() on a failure exit

Fixes: 6a9d552483d50 "media: rc: bpf attach/detach requires write permission" # v6.9
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarZhangPeng <zhangpeng362@huawei.com>
parent ed4da1fb
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -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;