]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
media: v4l: async: fix unregister for implicitly registered sub-device notifiers
authorNiklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Sat, 4 Nov 2017 02:25:56 +0000 (22:25 -0400)
committerMauro Carvalho Chehab <mchehab@s-opensource.com>
Tue, 7 Nov 2017 08:07:20 +0000 (03:07 -0500)
The commit aef69d54755d45ed ("media: v4l: fwnode: Add a convenience
function for registering sensors") adds the function
v4l2_async_notifier_parse_fwnode_sensor_common() to parse and register a
subdevice and a subdev-notifier by parsing firmware information. This
new subdev-notifier is stored in the new field 'subdev_notifier' in
struct v4l2_subdev.

In v4l2_async_unregister_subdev() this field is used to unregister and
cleanup the subdev-notifier. A check for if the subdev-notifier is
initialized or not was forgotten leading to a NULL pointer dereference
in v4l2_async_notifier_cleanup() if a subdevice do not use the optional
convince function to initialize the field.

Fix this by checking in v4l2_async_notifier_cleanup() that it is
provided whit a notifier making it safe to call with a NULL parameter.

Fixes: aef69d54755d45ed ("media: v4l: fwnode: Add a convenience function for registering sensors")
Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
drivers/media/v4l2-core/v4l2-async.c

index 7020b2e6d158ae7771e4af0acd3d9462eefe86dd..a7c3464976f2436133cbe729a2a1ef507c72c926 100644 (file)
@@ -502,7 +502,7 @@ void v4l2_async_notifier_cleanup(struct v4l2_async_notifier *notifier)
 {
        unsigned int i;
 
-       if (!notifier->max_subdevs)
+       if (!notifier || !notifier->max_subdevs)
                return;
 
        for (i = 0; i < notifier->num_subdevs; i++) {