* [PATCH] media: msi2500: fix memory leak in msi2500_probe error path
@ 2026-05-10 1:57 Daiki Harada
2026-05-14 16:33 ` Kohei Enju
0 siblings, 1 reply; 2+ messages in thread
From: Daiki Harada @ 2026-05-10 1:57 UTC (permalink / raw)
To: linux-media, linux-kernel
Cc: Mauro Carvalho Chehab, Daiki Harada, Kees Cook,
syzbot+b1de0d5fd8a15fac11aa
When video_register_device() fails in msi2500_probe(), the error path
jumps to err_unregister_v4l2_dev, which skips the call to
v4l2_ctrl_handler_free(). This leaks memory allocated by
v4l2_ctrl_handler_init() and v4l2_ctrl_add_handler().
Fix this by jumping to err_free_controls instead, which properly frees
the control handler before unregistering the v4l2 device.
Reported-by: syzbot+b1de0d5fd8a15fac11aa@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=b1de0d5fd8a15fac11aa
Tested-by: syzbot+b1de0d5fd8a15fac11aa@syzkaller.appspotmail.com
Signed-off-by: Daiki Harada <daiky0325@gmail.com>
---
drivers/media/usb/msi2500/msi2500.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/media/usb/msi2500/msi2500.c b/drivers/media/usb/msi2500/msi2500.c
index 1ff98956b680..76e1f2bfab0c 100644
--- a/drivers/media/usb/msi2500/msi2500.c
+++ b/drivers/media/usb/msi2500/msi2500.c
@@ -1265,7 +1265,7 @@ static int msi2500_probe(struct usb_interface *intf,
if (ret) {
dev_err(dev->dev,
"Failed to register as video device (%d)\n", ret);
- goto err_unregister_v4l2_dev;
+ goto err_free_controls;
}
dev_info(dev->dev, "Registered as %s\n",
video_device_node_name(&dev->vdev));
--
2.54.0
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] media: msi2500: fix memory leak in msi2500_probe error path
2026-05-10 1:57 [PATCH] media: msi2500: fix memory leak in msi2500_probe error path Daiki Harada
@ 2026-05-14 16:33 ` Kohei Enju
0 siblings, 0 replies; 2+ messages in thread
From: Kohei Enju @ 2026-05-14 16:33 UTC (permalink / raw)
To: daiky0325
Cc: kees, linux-kernel, linux-media, mchehab,
syzbot+b1de0d5fd8a15fac11aa
On Sun, 10 May 2026 01:57:55 +0000, Daiki Harada wrote:
> When video_register_device() fails in msi2500_probe(), the error path
> jumps to err_unregister_v4l2_dev, which skips the call to
> v4l2_ctrl_handler_free(). This leaks memory allocated by
> v4l2_ctrl_handler_init() and v4l2_ctrl_add_handler().
>
> Fix this by jumping to err_free_controls instead, which properly frees
> the control handler before unregistering the v4l2 device.
>
Is the missing Fixes: tag intentional?
As far as I can tell from git blame, the Fixes tag might be:
Fixes: 2e68f841a5d1 ("[media] msi3101: use msi001 tuner driver")
That commit changed both the initialization sequence and the cleanup sequence on
failures, but didn't update the label it jumped to when video_register_device()
fails.
Otherwise, it looks good to me.
Side note:
The code has changed quite a bit since the commit, including a function rename,
so I am not sure whether this can be cleanly backported to older stable trees.
Still, the Fixes tag might be helpful.
> Reported-by: syzbot+b1de0d5fd8a15fac11aa@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=b1de0d5fd8a15fac11aa
> Tested-by: syzbot+b1de0d5fd8a15fac11aa@syzkaller.appspotmail.com
> Signed-off-by: Daiki Harada <daiky0325@gmail.com>
> ---
> drivers/media/usb/msi2500/msi2500.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/media/usb/msi2500/msi2500.c b/drivers/media/usb/msi2500/msi2500.c
> index 1ff98956b680..76e1f2bfab0c 100644
> --- a/drivers/media/usb/msi2500/msi2500.c
> +++ b/drivers/media/usb/msi2500/msi2500.c
> @@ -1265,7 +1265,7 @@ static int msi2500_probe(struct usb_interface *intf,
> if (ret) {
> dev_err(dev->dev,
> "Failed to register as video device (%d)\n", ret);
> - goto err_unregister_v4l2_dev;
> + goto err_free_controls;
> }
> dev_info(dev->dev, "Registered as %s\n",
> video_device_node_name(&dev->vdev));
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-05-14 17:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-10 1:57 [PATCH] media: msi2500: fix memory leak in msi2500_probe error path Daiki Harada
2026-05-14 16:33 ` Kohei Enju
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox