media: v4l2-async: Safely unregister an non-registered async subdev
authorLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Thu, 7 Jan 2021 22:54:58 +0000 (23:54 +0100)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Wed, 27 Jan 2021 14:49:21 +0000 (15:49 +0100)
Make the V4L2 async framework a bit more robust by allowing to
unregister a non-registered async subdev. Otherwise the
v4l2_async_cleanup() will attempt to delete the async subdev from the
subdev_list with the corresponding list_head not initialized.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/media/v4l2-core/v4l2-async.c

index 3db8e2a929829d02526ab954fcbb761d6780902a..64643b1697834d81a14f52c7b8cb3fe3a0854e4d 100644 (file)
@@ -813,6 +813,9 @@ EXPORT_SYMBOL(v4l2_async_register_subdev);
 
 void v4l2_async_unregister_subdev(struct v4l2_subdev *sd)
 {
+       if (!sd->async_list.next)
+               return;
+
        mutex_lock(&list_lock);
 
        __v4l2_async_notifier_unregister(sd->subdev_notifier);