[media] v4l2-ctrls.c: add NULL check
authorHans Verkuil <hverkuil@xs4all.nl>
Wed, 25 Jan 2017 07:38:07 +0000 (05:38 -0200)
committerMauro Carvalho Chehab <mchehab@s-opensource.com>
Fri, 3 Feb 2017 13:24:48 +0000 (11:24 -0200)
Check that the control whose events we want to delete is still there.

Normally this will always be the case, but I am not 100% certain if
there aren't any corner cases when a device is forcibly unbound.

In any case, this will satisfy static checkers and simply make it more
robust.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Reported-by: Shaobo <shaobo@cs.utah.edu>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
drivers/media/v4l2-core/v4l2-ctrls.c

index 47001e25fd9eeade8ec028c51f2d2482f633db98..b9e08e3d6e0e7d52deeed2d8d9d2d51f6622659c 100644 (file)
@@ -3367,6 +3367,9 @@ static void v4l2_ctrl_del_event(struct v4l2_subscribed_event *sev)
 {
        struct v4l2_ctrl *ctrl = v4l2_ctrl_find(sev->fh->ctrl_handler, sev->id);
 
+       if (ctrl == NULL)
+               return;
+
        v4l2_ctrl_lock(ctrl);
        list_del(&sev->node);
        v4l2_ctrl_unlock(ctrl);