[PATCH] media: cx231xx: don't free the media device on err_analog
From: Farhad Alemi
Date: Fri Sep 11 2026 - 01:49:03 EST
When cx231xx_register_analog_devices() fails, cx231xx_init_dev() jumps to
err_analog and calls cx231xx_unregister_media_device(), which frees
dev->media_dev while dev->v4l2_dev.mdev still aliases it. The next line,
cx231xx_release_analog_resources(), releases the video device, so
v4l2_device_release() takes the freed media device's graph_mutex in
media_devnode_remove(). Remove that free from err_analog and leave it to
cx231xx_usb_probe(), which frees the media device at err_v4l2, after
cx231xx_release_analog_resources() has released the video devices and
v4l2_device_unregister() has dropped the subdevs.
Signed-off-by: Farhad Alemi <farhad.alemi@xxxxxxxxxxxx>
---
The device was emulated.
--- a/drivers/media/usb/cx231xx/cx231xx-cards.c
+++ b/drivers/media/usb/cx231xx/cx231xx-cards.c
@@ -1505,7 +1505,7 @@ static int cx231xx_init_dev(struct cx231xx *dev,
struct usb_device *udev,
return 0;
err_analog:
- cx231xx_unregister_media_device(dev);
+ /* dev->v4l2_dev.mdev aliases media_dev until probe's err_v4l2 frees it. */
cx231xx_release_analog_resources(dev);
cx231xx_remove_from_devlist(dev);
err_dev_init: