From: ssrane_b23@ee.vjti.ac.in
To: hverkuil@kernel.org
Cc: mchehab@kernel.org, linux-media@vger.kernel.org,
linux-kernel@vger.kernel.org, skhan@linuxfoundation.org,
linux-kernel-mentees@lists.linux.dev,
david.hunter.linux@gmail.com, khalid@kernel.org,
Shaurya Rane <ssrane_b23@ee.vjti.ac.in>,
syzbot+a41b73dce23962a74c72@syzkaller.appspotmail.com
Subject: [PATCH] media: radio-keene: fix memory leak in error path
Date: Wed, 26 Nov 2025 09:11:05 +0530 [thread overview]
Message-ID: <20251126034105.236131-1-ssranevjti@gmail.com> (raw)
From: Shaurya Rane <ssrane_b23@ee.vjti.ac.in>
Fix a memory leak in usb_keene_probe() when v4l2_device_register()
fails. The v4l2 control handler was initialized and controls were
added, but if v4l2_device_register() failed, the handler was never
freed, leaking the allocated memory for the handler buckets and
control structures.
Fixes the error handling by adding an err_hdl label that
ensures v4l2_ctrl_handler_free() is called for all error paths
after the handler is initialized.
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 | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/media/radio/radio-keene.c b/drivers/media/radio/radio-keene.c
index f3b57f0cb1ec..84916b5ebcb2 100644
--- a/drivers/media/radio/radio-keene.c
+++ b/drivers/media/radio/radio-keene.c
@@ -337,14 +337,12 @@ static int usb_keene_probe(struct usb_interface *intf,
radio->stereo = true;
if (hdl->error) {
retval = hdl->error;
-
- v4l2_ctrl_handler_free(hdl);
- goto err_v4l2;
+ goto err_hdl;
}
retval = v4l2_device_register(&intf->dev, &radio->v4l2_dev);
if (retval < 0) {
dev_err(&intf->dev, "couldn't register v4l2_device\n");
- goto err_v4l2;
+ goto err_hdl;
}
mutex_init(&radio->lock);
@@ -383,6 +381,8 @@ static int usb_keene_probe(struct usb_interface *intf,
err_vdev:
v4l2_device_unregister(&radio->v4l2_dev);
+err_hdl:
+ v4l2_ctrl_handler_free(&radio->hdl);
err_v4l2:
kfree(radio->buffer);
kfree(radio);
--
2.34.1
next reply other threads:[~2025-11-26 3:41 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-26 3:41 ssrane_b23 [this message]
2025-11-27 16:56 ` [PATCH] media: radio-keene: fix memory leak in error path David Hunter
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=20251126034105.236131-1-ssranevjti@gmail.com \
--to=ssrane_b23@ee.vjti.ac.in \
--cc=david.hunter.linux@gmail.com \
--cc=hverkuil@kernel.org \
--cc=khalid@kernel.org \
--cc=linux-kernel-mentees@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=skhan@linuxfoundation.org \
--cc=syzbot+a41b73dce23962a74c72@syzkaller.appspotmail.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