On Mon Jun 29 08:47:05 2026 +0200, Hans Verkuil wrote:
> When my em28xx USB device that uses the i2c tvp5150 driver is
> disconnected, it crashes.
>
> The cause is that the tvp5150 i2c module uses v4l2_async, but
> the em28xx driver does not since it predates v4l2_async.
>
> In that corner case sd->asc_list is empty, so
> v4l2_async_unregister_subdev() never calls v4l2_device_unregister_subdev().
>
> Modify the code so that, if sd->asc_list is empty,
> v4l2_device_unregister_subdev() is still called.
>
> Fixes: 28a1295795d8 ("media: v4l: async: Allow multiple connections between
> entities")
> Signed-off-by: Hans Verkuil <[email protected]>
> Acked-by: Sakari Ailus <[email protected]>
> Tested-by: Hans Verkuil <[email protected]>
> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
Patch committed.
Thanks,
Mauro Carvalho Chehab
drivers/media/v4l2-core/v4l2-async.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
---
diff --git a/drivers/media/v4l2-core/v4l2-async.c
b/drivers/media/v4l2-core/v4l2-async.c
index 888a2e213b08..f36d60e6ff41 100644
--- a/drivers/media/v4l2-core/v4l2-async.c
+++ b/drivers/media/v4l2-core/v4l2-async.c
@@ -898,9 +898,18 @@ void v4l2_async_unregister_subdev(struct v4l2_subdev *sd)
sd->subdev_notifier = NULL;
if (sd->asc_list.next) {
- list_for_each_entry_safe(asc, asc_tmp, &sd->asc_list,
- asc_subdev_entry) {
- v4l2_async_unbind_subdev_one(asc->notifier, asc);
+ if (list_empty(&sd->asc_list)) {
+ /*
+ * If the sub-device was registered through other means
+ * than v4l2-async, there are no async connections but
+ * the sub-device may still well be registered.
+ * Unregister it now.
+ */
+ v4l2_device_unregister_subdev(sd);
+ } else {
+ list_for_each_entry_safe(asc, asc_tmp, &sd->asc_list,
+ asc_subdev_entry)
+ v4l2_async_unbind_subdev_one(asc->notifier,
asc);
}
}
_______________________________________________
linuxtv-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]