From patchwork Fri Jan 28 02:04:33 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephan Lachowsky X-Patchwork-Id: 513541 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p0S24gp8009994 for ; Fri, 28 Jan 2011 02:04:43 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753900Ab1A1CEg (ORCPT ); Thu, 27 Jan 2011 21:04:36 -0500 Received: from antispam01.maxim-ic.com ([205.153.101.182]:36816 "EHLO antispam01.dummydomain.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752963Ab1A1CEg (ORCPT ); Thu, 27 Jan 2011 21:04:36 -0500 X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Fri, 28 Jan 2011 02:04:43 +0000 (UTC) X-Greylist: delayed 809 seconds by postgrey-1.27 at vger.kernel.org; Thu, 27 Jan 2011 21:04:36 EST X-ASG-Debug-ID: 1296180275-621405af0001-rVgMWv Received: from terlingua.dalsemi.com (terlingua.dalsemi.com [180.0.34.46]) by antispam01.dummydomain.com with ESMTP id ejuQKcDpuzXBaaQS for ; Thu, 27 Jan 2011 20:04:35 -0600 (CST) X-Barracuda-Envelope-From: stephan.lachowsky@maxim-ic.com X-Barracuda-Apparent-Source-IP: 180.0.34.46 Received: from maxdalex02.maxim-ic.internal (maxdalex02.maxim-ic.internal [10.16.15.104]) by terlingua.dalsemi.com (8.10.2/8.10.2) with ESMTP id p0S24ZI16210 for ; Thu, 27 Jan 2011 20:04:35 -0600 (CST) Received: from maxsvlex01.maxim-ic.internal (172.18.47.214) by maxdalex02.maxim-ic.internal (10.16.15.104) with Microsoft SMTP Server (TLS) id 8.3.83.0; Thu, 27 Jan 2011 20:04:34 -0600 Received: from [10.32.80.201] (10.32.80.201) by maxsvlex01.maxim-ic.internal (172.18.47.214) with Microsoft SMTP Server (TLS) id 8.3.83.0; Thu, 27 Jan 2011 18:04:33 -0800 Subject: [PATCH] uvcvideo: Fix uvc_fixup_video_ctrl() format search From: Stephan Lachowsky X-ASG-Orig-Subj: [PATCH] uvcvideo: Fix uvc_fixup_video_ctrl() format search To: "linux-media@vger.kernel.org" Date: Thu, 27 Jan 2011 18:04:33 -0800 Message-ID: <1296180273.17673.5.camel@svmlwks101> MIME-Version: 1.0 X-Mailer: Evolution 2.32.1 (2.32.1-1.fc14) X-Barracuda-Connect: terlingua.dalsemi.com[180.0.34.46] X-Barracuda-Start-Time: 1296180275 X-Barracuda-URL: http://AntiSpam02.maxim-ic.com:8000/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at dummydomain.com X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=5.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.2.53641 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org diff --git a/drivers/media/video/uvc/uvc_video.c b/drivers/media/video/uvc/uvc_video.c index 5673d67..545c029 100644 --- a/drivers/media/video/uvc/uvc_video.c +++ b/drivers/media/video/uvc/uvc_video.c @@ -89,15 +89,19 @@ int uvc_query_ctrl(struct uvc_device *dev, __u8 query, __u8 unit, static void uvc_fixup_video_ctrl(struct uvc_streaming *stream, struct uvc_streaming_control *ctrl) { - struct uvc_format *format; + struct uvc_format *format = NULL; struct uvc_frame *frame = NULL; unsigned int i; - if (ctrl->bFormatIndex <= 0 || - ctrl->bFormatIndex > stream->nformats) - return; + for (i = 0; i < stream->nformats; ++i) { + if (stream->format[i].index == ctrl->bFormatIndex) { + format = &stream->format[i]; + break; + } + } - format = &stream->format[ctrl->bFormatIndex - 1]; + if (format == NULL) + return; for (i = 0; i < format->nframes; ++i) { if (format->frame[i].bFrameIndex == ctrl->bFrameIndex) {