summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorSakari Ailus <sakari.ailus@linux.intel.com>2023-12-07 12:00:02 +0200
committerHans Verkuil <hverkuil-cisco@xs4all.nl>2023-12-13 13:21:20 +0100
commitab8d7194acd1fea1702fff41a1ec93e458b6dcbf (patch)
treef061586f9b971c07f08dbc1a991797a8b474baca /drivers
parentfb16c04a538e1fa177bf2dcdf763292d51fe6e2b (diff)
media: v4l: Safely to call v4l2_subdev_cleanup on an uninitialised subdev
Graciously handle an uninitialised (but still zeroed) sub-device in v4l2_subdev_cleanup(). The list_empty() check there is unnecessary, too, so replace that by cheking whether the lists's next field is NULL. Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/v4l2-core/v4l2-subdev.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
index 4fbefe4cd714..1fa1acfa5b7b 100644
--- a/drivers/media/v4l2-core/v4l2-subdev.c
+++ b/drivers/media/v4l2-core/v4l2-subdev.c
@@ -1521,7 +1521,8 @@ void v4l2_subdev_cleanup(struct v4l2_subdev *sd)
__v4l2_subdev_state_free(sd->active_state);
sd->active_state = NULL;
- if (list_empty(&sd->async_subdev_endpoint_list))
+ /* Uninitialised sub-device, bail out here. */
+ if (!sd->async_subdev_endpoint_list.next)
return;
list_for_each_entry_safe(ase, ase_tmp, &sd->async_subdev_endpoint_list,