Linux kernel staging patches
 help / color / mirror / Atom feed
* [PATCH] staging: most: video: fix refcount leak in comp_probe_channel()
@ 2026-06-11 11:43 WenTao Liang
  2026-06-11 12:48 ` Dan Carpenter
  0 siblings, 1 reply; 2+ messages in thread
From: WenTao Liang @ 2026-06-11 11:43 UTC (permalink / raw)
  To: parthiban.veerasooran, christian.gromm, gregkh
  Cc: hverkuil+cisco, laurent.pinchart+renesas, s9430939, error27,
	vulab, kees, linux-staging, linux-kernel, stable

If v4l2_device_register() fails in comp_probe_channel(), the
function frees the allocated mdev with kfree() without releasing the
reference count held by the embedded v4l2_device.  Because
v4l2_device_register() initializes a kref in the v4l2_device, the
reference count is already 1 on failure.  Dropping the last reference
must be done with v4l2_device_put() so that the release callback can
unregister the v4l2_device and free mdev.

Replace the kfree(mdev) with v4l2_device_put(&mdev->v4l2_dev).  The
error path for comp_register_videodev() failure already does this
correctly.

Cc: stable@vger.kernel.org
Fixes: 3d31c0cb6c12 ("Staging: most: add MOST driver's aim-v4l2 module")
Signed-off-by: WenTao Liang <vulab@iscas.ac.cn>
---
 drivers/staging/most/video/video.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/most/video/video.c b/drivers/staging/most/video/video.c
index 04351f8ccccf..aa846959b217 100644
--- a/drivers/staging/most/video/video.c
+++ b/drivers/staging/most/video/video.c
@@ -491,7 +491,7 @@ static int comp_probe_channel(struct most_interface *iface, int channel_idx,
 	ret = v4l2_device_register(NULL, &mdev->v4l2_dev);
 	if (ret) {
 		pr_err("v4l2_device_register() failed\n");
-		kfree(mdev);
+		v4l2_device_put(&mdev->v4l2_dev);
 		return ret;
 	}
 
-- 
2.50.1 (Apple Git-155)


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

end of thread, other threads:[~2026-06-11 12:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-11 11:43 [PATCH] staging: most: video: fix refcount leak in comp_probe_channel() WenTao Liang
2026-06-11 12:48 ` Dan Carpenter

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