aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/uvc
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2010-04-25 15:27:14 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-05-19 11:58:44 -0400
commitcf7a50eeb6f462a0b7d1619fcb27a727a2981769 (patch)
treeae71d7dfc5af77429f9d881d59ab98f08353c170 /drivers/media/video/uvc
parenta90ef69c1f67319ddbba0170767c660c7fb5d4c9 (diff)
V4L/DVB: uvcvideo: Prevent division by 0 when control step value is 0
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>
Diffstat (limited to 'drivers/media/video/uvc')
-rw-r--r--drivers/media/video/uvc/uvc_ctrl.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/media/video/uvc/uvc_ctrl.c b/drivers/media/video/uvc/uvc_ctrl.c
index 2703c9524396..aa0720af07a0 100644
--- a/drivers/media/video/uvc/uvc_ctrl.c
+++ b/drivers/media/video/uvc/uvc_ctrl.c
@@ -1071,6 +1071,8 @@ int uvc_ctrl_set(struct uvc_video_chain *chain,
1071 uvc_ctrl_data(ctrl, UVC_CTRL_DATA_MAX)); 1071 uvc_ctrl_data(ctrl, UVC_CTRL_DATA_MAX));
1072 step = mapping->get(mapping, UVC_GET_RES, 1072 step = mapping->get(mapping, UVC_GET_RES,
1073 uvc_ctrl_data(ctrl, UVC_CTRL_DATA_RES)); 1073 uvc_ctrl_data(ctrl, UVC_CTRL_DATA_RES));
1074 if (step == 0)
1075 step = 1;
1074 1076
1075 xctrl->value = min + (xctrl->value - min + step/2) / step * step; 1077 xctrl->value = min + (xctrl->value - min + step/2) / step * step;
1076 xctrl->value = clamp(xctrl->value, min, max); 1078 xctrl->value = clamp(xctrl->value, min, max);