V4L/DVB: uvcvideo: Prevent division by 0 when control step value is 0
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Sun, 25 Apr 2010 19:27:14 +0000 (16:27 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Wed, 19 May 2010 15:58:44 +0000 (12:58 -0300)
The control step values reported by the device are used as a divisor
unchecked, which can result in a division by zero.

Check the step value and make it 1 when null.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/video/uvc/uvc_ctrl.c

index 2703c95243961af195145116844b467ee2028185..aa0720af07a0e78abadd83a2eb8d79ba55b3560e 100644 (file)
@@ -1071,6 +1071,8 @@ int uvc_ctrl_set(struct uvc_video_chain *chain,
                                   uvc_ctrl_data(ctrl, UVC_CTRL_DATA_MAX));
                step = mapping->get(mapping, UVC_GET_RES,
                                    uvc_ctrl_data(ctrl, UVC_CTRL_DATA_RES));
+               if (step == 0)
+                       step = 1;
 
                xctrl->value = min + (xctrl->value - min + step/2) / step * step;
                xctrl->value = clamp(xctrl->value, min, max);