From 25a6436002d3bf2cc7483d0bfcf4373c3552f375 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Thu, 7 Jan 2021 23:54:58 +0100 Subject: media: v4l2-async: Safely unregister an non-registered async subdev 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 Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- drivers/media/v4l2-core/v4l2-async.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers/media') diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c index 3db8e2a92982..64643b169783 100644 --- a/drivers/media/v4l2-core/v4l2-async.c +++ b/drivers/media/v4l2-core/v4l2-async.c @@ -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); -- cgit v1.2.3