diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2011-04-30 08:46:11 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-05-20 08:30:45 -0400 |
commit | f411f103822379bab356345430f097bdae3440e5 (patch) | |
tree | 78a74656a8978e2021a8bdd0575ae9207cea7e96 /drivers/media | |
parent | fc2d573fb4e65393688d32bc128c70ddd8ecccc6 (diff) |
[media] uvcvideo: Return -ERANGE when userspace sets an unsupported menu entry
Instead of passing the value down to the device and getting an error
back (or worse, crashing the firmware), return -ERANGE when the
requested menu entry is not supported.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/video/uvc/uvc_ctrl.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/drivers/media/video/uvc/uvc_ctrl.c b/drivers/media/video/uvc/uvc_ctrl.c index 0dc2a9f7ca51..a4db26fa2f53 100644 --- a/drivers/media/video/uvc/uvc_ctrl.c +++ b/drivers/media/video/uvc/uvc_ctrl.c | |||
@@ -1221,6 +1221,23 @@ int uvc_ctrl_set(struct uvc_video_chain *chain, | |||
1221 | if (xctrl->value < 0 || xctrl->value >= mapping->menu_count) | 1221 | if (xctrl->value < 0 || xctrl->value >= mapping->menu_count) |
1222 | return -ERANGE; | 1222 | return -ERANGE; |
1223 | value = mapping->menu_info[xctrl->value].value; | 1223 | value = mapping->menu_info[xctrl->value].value; |
1224 | |||
1225 | /* Valid menu indices are reported by the GET_RES request for | ||
1226 | * UVC controls that support it. | ||
1227 | */ | ||
1228 | if (ctrl->info.flags & UVC_CTRL_FLAG_GET_RES) { | ||
1229 | if (!ctrl->cached) { | ||
1230 | ret = uvc_ctrl_populate_cache(chain, ctrl); | ||
1231 | if (ret < 0) | ||
1232 | return ret; | ||
1233 | } | ||
1234 | |||
1235 | step = mapping->get(mapping, UVC_GET_RES, | ||
1236 | uvc_ctrl_data(ctrl, UVC_CTRL_DATA_RES)); | ||
1237 | if (!(step & value)) | ||
1238 | return -ERANGE; | ||
1239 | } | ||
1240 | |||
1224 | break; | 1241 | break; |
1225 | 1242 | ||
1226 | default: | 1243 | default: |