1 From c4ed8c66d79d707d89fe732ff5b97739edf1ba62 Mon Sep 17 00:00:00 2001
2 From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
3 Date: Thu, 8 Oct 2009 19:38:10 -0300
4 Subject: V4L/DVB (13154): uvcvideo: Handle garbage at the end of streaming interface descriptors
6 From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
8 commit c4ed8c66d79d707d89fe732ff5b97739edf1ba62 upstream.
10 At least one 5986:0241 webcam model includes vendor-specific descriptors
11 at the end of its streaming interface descriptors. Print an information
12 UVC_TRACE_DESCR message and try to continue parsing the descriptors
13 rather than bailing out with an error.
15 Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
16 Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
17 Cc: maximilian attems <max@stro.at>
18 Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
21 drivers/media/video/uvc/uvc_driver.c | 14 +++++++++++---
22 1 file changed, 11 insertions(+), 3 deletions(-)
24 --- a/drivers/media/video/uvc/uvc_driver.c
25 +++ b/drivers/media/video/uvc/uvc_driver.c
26 @@ -436,7 +436,8 @@ static int uvc_parse_format(struct uvc_d
27 /* Parse the frame descriptors. Only uncompressed, MJPEG and frame
28 * based formats have frame descriptors.
30 - while (buflen > 2 && buffer[2] == ftype) {
31 + while (buflen > 2 && buffer[1] == USB_DT_CS_INTERFACE &&
32 + buffer[2] == ftype) {
33 frame = &format->frame[format->nframes];
34 if (ftype != UVC_VS_FRAME_FRAME_BASED)
35 n = buflen > 25 ? buffer[25] : 0;
36 @@ -513,12 +514,14 @@ static int uvc_parse_format(struct uvc_d
40 - if (buflen > 2 && buffer[2] == UVC_VS_STILL_IMAGE_FRAME) {
41 + if (buflen > 2 && buffer[1] == USB_DT_CS_INTERFACE &&
42 + buffer[2] == UVC_VS_STILL_IMAGE_FRAME) {
47 - if (buflen > 2 && buffer[2] == UVC_VS_COLORFORMAT) {
48 + if (buflen > 2 && buffer[1] == USB_DT_CS_INTERFACE &&
49 + buffer[2] == UVC_VS_COLORFORMAT) {
51 uvc_trace(UVC_TRACE_DESCR, "device %d videostreaming "
52 "interface %d COLORFORMAT error\n",
53 @@ -759,6 +762,11 @@ static int uvc_parse_streaming(struct uv
58 + uvc_trace(UVC_TRACE_DESCR, "device %d videostreaming interface "
59 + "%d has %u bytes of trailing descriptor garbage.\n",
60 + dev->udev->devnum, alts->desc.bInterfaceNumber, buflen);
62 /* Parse the alternate settings to find the maximum bandwidth. */
63 for (i = 0; i < intf->num_altsetting; ++i) {
64 struct usb_host_endpoint *ep;