Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Sakari Ailus and committed by
Hans Verkuil
ab8d7194 fb16c04a

+2 -1
+2 -1
drivers/media/v4l2-core/v4l2-subdev.c
··· 1521 1521 __v4l2_subdev_state_free(sd->active_state); 1522 1522 sd->active_state = NULL; 1523 1523 1524 - if (list_empty(&sd->async_subdev_endpoint_list)) 1524 + /* Uninitialised sub-device, bail out here. */ 1525 + if (!sd->async_subdev_endpoint_list.next) 1525 1526 return; 1526 1527 1527 1528 list_for_each_entry_safe(ase, ase_tmp, &sd->async_subdev_endpoint_list,