linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: shaurya <ssranevjti@gmail.com>
To: syzbot+a41b73dce23962a74c72@syzkaller.appspotmail.com
Cc: linux-kernel@vger.kernel.org, linux-media@vger.kernel.org,
	linux-usb@vger.kernel.org, syzkaller-bugs@googlegroups.com
Subject: Re: [syzbot] [media?] [usb?] memory leak in v4l2_ctrl_handler_init_class (2)
Date: Tue, 25 Nov 2025 22:33:29 +0530	[thread overview]
Message-ID: <ca9d89ca-4da9-4f2b-bd92-3791cae54911@gmail.com> (raw)
In-Reply-To: <692560ec.a70a0220.2ea503.0087.GAE@google.com>

[-- Attachment #1: Type: text/plain, Size: 83 bytes --]

#syz test:
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master

[-- Attachment #2: 0001-media-radio-keene-fix-memory-leak-in-probe.patch --]
[-- Type: text/x-patch, Size: 1585 bytes --]

From 93e6a2f0b39e276db2181167f797e234fa8014a2 Mon Sep 17 00:00:00 2001
From: Shaurya Rane <ssrane_b23@ee.vjti.ac.in>
Date: Tue, 25 Nov 2025 22:24:29 +0530
Subject: [PATCH] media: radio-keene: fix memory leak in probe

The usb_keene_probe() function allocates memory for the v4l2 control
handler using v4l2_ctrl_handler_init(). However, if the probe fails
later (e.g. in v4l2_device_register() or video_register_device()),
this memory is never freed, leading to a leak.

Fix this by adding v4l2_ctrl_handler_free() to the error path.

Reported-by: syzbot+a41b73dce23962a74c72@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=a41b73dce23962a74c72
Fixes: 1bf20c3a0c61 ("[media] radio-keene: add a driver for the Keene FM Transmitter")
Signed-off-by: Shaurya Rane <ssrane_b23@ee.vjti.ac.in>
---
 drivers/media/radio/radio-keene.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/radio/radio-keene.c b/drivers/media/radio/radio-keene.c
index f3b57f0cb1ec..c133305fd019 100644
--- a/drivers/media/radio/radio-keene.c
+++ b/drivers/media/radio/radio-keene.c
@@ -338,7 +338,6 @@ static int usb_keene_probe(struct usb_interface *intf,
 	if (hdl->error) {
 		retval = hdl->error;
 
-		v4l2_ctrl_handler_free(hdl);
 		goto err_v4l2;
 	}
 	retval = v4l2_device_register(&intf->dev, &radio->v4l2_dev);
@@ -384,6 +383,7 @@ static int usb_keene_probe(struct usb_interface *intf,
 err_vdev:
 	v4l2_device_unregister(&radio->v4l2_dev);
 err_v4l2:
+	v4l2_ctrl_handler_free(&radio->hdl);
 	kfree(radio->buffer);
 	kfree(radio);
 err:
-- 
2.34.1


  parent reply	other threads:[~2025-11-25 17:03 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-25  7:55 [syzbot] [media?] [usb?] memory leak in v4l2_ctrl_handler_init_class (2) syzbot
2025-11-25 17:01 ` shaurya
2025-11-25 20:38   ` syzbot
2025-11-25 17:03 ` shaurya [this message]
2025-11-25 21:09   ` syzbot
2025-11-25 20:21 ` shaurya
2025-11-25 21:29   ` syzbot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ca9d89ca-4da9-4f2b-bd92-3791cae54911@gmail.com \
    --to=ssranevjti@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=syzbot+a41b73dce23962a74c72@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).