linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFT][PATCH v1] media: zr364xx: Fix memory leak in ->probe()
@ 2020-12-30 21:19 Andy Shevchenko
  2020-12-31  1:53 ` Ezequiel Garcia
  2021-01-05 14:00 ` Dan Carpenter
  0 siblings, 2 replies; 6+ messages in thread
From: Andy Shevchenko @ 2020-12-30 21:19 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Linux Media Mailing List, royale, USB,
	syzkaller-bugs
  Cc: Andy Shevchenko, syzbot+b4d54814b339b5c6bbd4

When ->probe() fails in some cases it may not free resources.
Replace few separated calls by v4l2_device_put() to clean up
everything.

Reported-by: syzbot+b4d54814b339b5c6bbd4@syzkaller.appspotmail.com
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
I have no hardware and hadn't done any test of this.

 drivers/media/usb/zr364xx/zr364xx.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/media/usb/zr364xx/zr364xx.c b/drivers/media/usb/zr364xx/zr364xx.c
index 1e1c6b4d1874..5b9e31af57cf 100644
--- a/drivers/media/usb/zr364xx/zr364xx.c
+++ b/drivers/media/usb/zr364xx/zr364xx.c
@@ -1533,9 +1533,7 @@ static int zr364xx_probe(struct usb_interface *intf,
 	return 0;
 
 fail:
-	v4l2_ctrl_handler_free(hdl);
-	v4l2_device_unregister(&cam->v4l2_dev);
-	kfree(cam);
+	v4l2_device_put(&cam->v4l2_dev);
 	return err;
 }
 
-- 
2.29.2


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

end of thread, other threads:[~2021-01-05 16:07 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-12-30 21:19 [RFT][PATCH v1] media: zr364xx: Fix memory leak in ->probe() Andy Shevchenko
2020-12-31  1:53 ` Ezequiel Garcia
2020-12-31  1:53   ` syzbot
2021-01-05 14:00 ` Dan Carpenter
2021-01-05 14:37   ` Andy Shevchenko
2021-01-05 16:04     ` Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).