V4L/DVB: uvcvideo: Return -ERANGE when setting a control to an out-of-range menu index
The V4L2 specification states that out of bounds control values must
either be clamped to the valid range or result in a -ERANGE error code.
Fix the driver to return -ERANGE instead of -EINVAL when setting a menu
control to an invalid value.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
diff --git a/drivers/media/video/uvc/uvc_ctrl.c b/drivers/media/video/uvc/uvc_ctrl.c
index 6157694..f4e5ba2 100644
--- a/drivers/media/video/uvc/uvc_ctrl.c
+++ b/drivers/media/video/uvc/uvc_ctrl.c
@@ -1006,7 +1006,7 @@
if (mapping->v4l2_type == V4L2_CTRL_TYPE_MENU) {
if (value < 0 || value >= mapping->menu_count)
- return -EINVAL;
+ return -ERANGE;
value = mapping->menu_info[value].value;
}