Linux kernel -stable discussions
 help / color / mirror / Atom feed
* [PATCH 5.10 1/3] media: dvbdev: Fix memleak in dvb_register_device
@ 2023-06-12 13:39 ovidiu.panait
  2023-06-12 13:39 ` [PATCH 5.10 2/3] media: dvbdev: fix error logic at dvb_register_device() ovidiu.panait
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: ovidiu.panait @ 2023-06-12 13:39 UTC (permalink / raw)
  To: stable; +Cc: Dinghao Liu, Sean Young, Mauro Carvalho Chehab, Ovidiu Panait

From: Dinghao Liu <dinghao.liu@zju.edu.cn>

commit 167faadfcf9339088910e9e85a1b711fcbbef8e9 upstream.

When device_create() fails, dvbdev and dvbdevfops should
be freed just like when dvb_register_media_device() fails.

Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com>
---
 drivers/media/dvb-core/dvbdev.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
index fea2d82300b0..52315434e0a9 100644
--- a/drivers/media/dvb-core/dvbdev.c
+++ b/drivers/media/dvb-core/dvbdev.c
@@ -545,6 +545,9 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
 	if (IS_ERR(clsdev)) {
 		pr_err("%s: failed to create device dvb%d.%s%d (%ld)\n",
 		       __func__, adap->num, dnames[type], id, PTR_ERR(clsdev));
+		dvb_media_device_free(dvbdev);
+		kfree(dvbdevfops);
+		kfree(dvbdev);
 		return PTR_ERR(clsdev);
 	}
 	dprintk("DVB: register adapter%d/%s%d @ minor: %i (0x%02x)\n",
-- 
2.39.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-06-19  7:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-12 13:39 [PATCH 5.10 1/3] media: dvbdev: Fix memleak in dvb_register_device ovidiu.panait
2023-06-12 13:39 ` [PATCH 5.10 2/3] media: dvbdev: fix error logic at dvb_register_device() ovidiu.panait
2023-06-12 13:39 ` [PATCH 5.10 3/3] media: dvb-core: Fix use-after-free due to race " ovidiu.panait
2023-06-19  7:50 ` [PATCH 5.10 1/3] media: dvbdev: Fix memleak in dvb_register_device Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox