Skip to content

Commit 0dc68ca

Browse files
kbinghammchehab
authored andcommitted
media: uvcvideo: Prevent setting unavailable flags
The addition of an extra operation to use the GET_INFO command overwrites all existing flags from the uvc_ctrls table. This includes setting all controls as supporting GET_MIN, GET_MAX, GET_RES, and GET_DEF regardless of whether they do or not. Move the initialisation of these control capabilities directly to the uvc_ctrl_fill_xu_info() call where they were originally located in that use case, and ensure that the new functionality in uvc_ctrl_get_flags() will only set flags based on their reported capability from the GET_INFO call. Fixes: 859086a ("media: uvcvideo: Apply flags from device to actual properties") Cc: stable@vger.kernel.org Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Tested-by: Guennadi Liakhovetski <guennadi.liakhovetski@intel.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
1 parent a00031c commit 0dc68ca

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

drivers/media/usb/uvc/uvc_ctrl.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1607,14 +1607,12 @@ static int uvc_ctrl_get_flags(struct uvc_device *dev,
16071607
ret = uvc_query_ctrl(dev, UVC_GET_INFO, ctrl->entity->id, dev->intfnum,
16081608
info->selector, data, 1);
16091609
if (!ret)
1610-
info->flags = UVC_CTRL_FLAG_GET_MIN | UVC_CTRL_FLAG_GET_MAX
1611-
| UVC_CTRL_FLAG_GET_RES | UVC_CTRL_FLAG_GET_DEF
1612-
| (data[0] & UVC_CONTROL_CAP_GET ?
1613-
UVC_CTRL_FLAG_GET_CUR : 0)
1614-
| (data[0] & UVC_CONTROL_CAP_SET ?
1615-
UVC_CTRL_FLAG_SET_CUR : 0)
1616-
| (data[0] & UVC_CONTROL_CAP_AUTOUPDATE ?
1617-
UVC_CTRL_FLAG_AUTO_UPDATE : 0);
1610+
info->flags |= (data[0] & UVC_CONTROL_CAP_GET ?
1611+
UVC_CTRL_FLAG_GET_CUR : 0)
1612+
| (data[0] & UVC_CONTROL_CAP_SET ?
1613+
UVC_CTRL_FLAG_SET_CUR : 0)
1614+
| (data[0] & UVC_CONTROL_CAP_AUTOUPDATE ?
1615+
UVC_CTRL_FLAG_AUTO_UPDATE : 0);
16181616

16191617
kfree(data);
16201618
return ret;
@@ -1689,6 +1687,9 @@ static int uvc_ctrl_fill_xu_info(struct uvc_device *dev,
16891687

16901688
info->size = le16_to_cpup((__le16 *)data);
16911689

1690+
info->flags = UVC_CTRL_FLAG_GET_MIN | UVC_CTRL_FLAG_GET_MAX
1691+
| UVC_CTRL_FLAG_GET_RES | UVC_CTRL_FLAG_GET_DEF;
1692+
16921693
ret = uvc_ctrl_get_flags(dev, ctrl, info);
16931694
if (ret < 0) {
16941695
uvc_trace(UVC_TRACE_CONTROL,

0 commit comments

Comments
 (0)