[PATCH] media: au0828: Fix media device leak in au0828_usb_probe()
From: Wentao Liang
Date: Thu Sep 17 2026 - 06:16:22 EST
au0828_media_device_init() takes a reference to a media device with
media_device_usb_allocate(). When au0828_v4l2_device_register()
fails right after, the error path only unregisters the entities and
frees au0828_dev, so that reference is never released.
Release it with media_device_delete() on that path.
Fixes: 812658d88d26 ("media: change au0828 to use Media Device Allocator API")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Wentao Liang <vulab@xxxxxxxxxxx>
---
drivers/media/usb/au0828/au0828-core.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/media/usb/au0828/au0828-core.c b/drivers/media/usb/au0828/au0828-core.c
index 445cbeb7abae..c3826b3b8a2e 100644
--- a/drivers/media/usb/au0828/au0828-core.c
+++ b/drivers/media/usb/au0828/au0828-core.c
@@ -697,6 +697,10 @@ static int au0828_usb_probe(struct usb_interface *interface,
retval = au0828_v4l2_device_register(interface, dev);
if (retval) {
au0828_usb_v4l2_media_release(dev);
+#ifdef CONFIG_MEDIA_CONTROLLER
+ media_device_delete(dev->media_dev, KBUILD_MODNAME,
+ THIS_MODULE);
+#endif
mutex_unlock(&dev->lock);
kfree(dev);
return retval;
--
2.34.1