From: Dan Carpenter Date: Tue, 31 Oct 2023 09:53:33 +0000 (+0300) Subject: media: dvbdev: drop refcount on error path in dvb_device_open() X-Git-Tag: v6.6.17~1088 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=de28d63ad35c7c58cb2e707db069a95e068c276b;p=platform%2Fkernel%2Flinux-rpi.git media: dvbdev: drop refcount on error path in dvb_device_open() [ Upstream commit a2dd235df435a05d389240be748909ada91201d2 ] If call to file->f_op->open() fails, then call dvb_device_put(dvbdev). Fixes: 0fc044b2b5e2 ("media: dvbdev: adopts refcnt to avoid UAF") Signed-off-by: Dan Carpenter Signed-off-by: Hans Verkuil Signed-off-by: Sasha Levin --- diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c index 305bb21..49f0eb7 100644 --- a/drivers/media/dvb-core/dvbdev.c +++ b/drivers/media/dvb-core/dvbdev.c @@ -104,6 +104,8 @@ static int dvb_device_open(struct inode *inode, struct file *file) err = file->f_op->open(inode, file); up_read(&minor_rwsem); mutex_unlock(&dvbdev_mutex); + if (err) + dvb_device_put(dvbdev); return err; } fail: