From patchwork Fri Jan 28 01:51:02 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephan Lachowsky X-Patchwork-Id: 513551 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 p0S2A8rK012592 for ; Fri, 28 Jan 2011 02:10:08 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753863Ab1A1CKD (ORCPT ); Thu, 27 Jan 2011 21:10:03 -0500 Received: from antispam01.maxim-ic.com ([205.153.101.182]:37151 "EHLO antispam01.dummydomain.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752963Ab1A1CKC (ORCPT ); Thu, 27 Jan 2011 21:10:02 -0500 X-ASG-Debug-ID: 1296179463-6212048a0001-rVgMWv Received: from terlingua.dalsemi.com (terlingua.dalsemi.com [180.0.34.46]) by antispam01.dummydomain.com with ESMTP id pr081V80SyRKhHpc for ; Thu, 27 Jan 2011 19:51:03 -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 p0S1p3I10051 for ; Thu, 27 Jan 2011 19:51:03 -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 19:51:03 -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 17:51:02 -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 17:51:02 -0800 Message-ID: <1296179462.17673.3.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: 1296179463 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 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:10:08 +0000 (UTC) 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) {