Commit c4ed8c66 authored by Laurent Pinchart's avatar Laurent Pinchart Committed by Mauro Carvalho Chehab

V4L/DVB (13154): uvcvideo: Handle garbage at the end of streaming interface descriptors

At least one 5986:0241 webcam model includes vendor-specific descriptors
at the end of its streaming interface descriptors. Print an information
UVC_TRACE_DESCR message and try to continue parsing the descriptors
rather than bailing out with an error.
Signed-off-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent fd1b6bbb
...@@ -426,7 +426,8 @@ static int uvc_parse_format(struct uvc_device *dev, ...@@ -426,7 +426,8 @@ static int uvc_parse_format(struct uvc_device *dev,
/* Parse the frame descriptors. Only uncompressed, MJPEG and frame /* Parse the frame descriptors. Only uncompressed, MJPEG and frame
* based formats have frame descriptors. * based formats have frame descriptors.
*/ */
while (buflen > 2 && buffer[2] == ftype) { while (buflen > 2 && buffer[1] == USB_DT_CS_INTERFACE &&
buffer[2] == ftype) {
frame = &format->frame[format->nframes]; frame = &format->frame[format->nframes];
if (ftype != UVC_VS_FRAME_FRAME_BASED) if (ftype != UVC_VS_FRAME_FRAME_BASED)
n = buflen > 25 ? buffer[25] : 0; n = buflen > 25 ? buffer[25] : 0;
...@@ -503,12 +504,14 @@ static int uvc_parse_format(struct uvc_device *dev, ...@@ -503,12 +504,14 @@ static int uvc_parse_format(struct uvc_device *dev,
buffer += buffer[0]; buffer += buffer[0];
} }
if (buflen > 2 && buffer[2] == UVC_VS_STILL_IMAGE_FRAME) { if (buflen > 2 && buffer[1] == USB_DT_CS_INTERFACE &&
buffer[2] == UVC_VS_STILL_IMAGE_FRAME) {
buflen -= buffer[0]; buflen -= buffer[0];
buffer += buffer[0]; buffer += buffer[0];
} }
if (buflen > 2 && buffer[2] == UVC_VS_COLORFORMAT) { if (buflen > 2 && buffer[1] == USB_DT_CS_INTERFACE &&
buffer[2] == UVC_VS_COLORFORMAT) {
if (buflen < 6) { if (buflen < 6) {
uvc_trace(UVC_TRACE_DESCR, "device %d videostreaming " uvc_trace(UVC_TRACE_DESCR, "device %d videostreaming "
"interface %d COLORFORMAT error\n", "interface %d COLORFORMAT error\n",
...@@ -749,6 +752,11 @@ static int uvc_parse_streaming(struct uvc_device *dev, ...@@ -749,6 +752,11 @@ static int uvc_parse_streaming(struct uvc_device *dev,
buffer += buffer[0]; buffer += buffer[0];
} }
if (buflen)
uvc_trace(UVC_TRACE_DESCR, "device %d videostreaming interface "
"%d has %u bytes of trailing descriptor garbage.\n",
dev->udev->devnum, alts->desc.bInterfaceNumber, buflen);
/* Parse the alternate settings to find the maximum bandwidth. */ /* Parse the alternate settings to find the maximum bandwidth. */
for (i = 0; i < intf->num_altsetting; ++i) { for (i = 0; i < intf->num_altsetting; ++i) {
struct usb_host_endpoint *ep; struct usb_host_endpoint *ep;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment