From patchwork Sun Mar 28 11:50:05 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 88761 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o2SBokKq003232 for ; Sun, 28 Mar 2010 11:50:46 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754374Ab0C1LuV (ORCPT ); Sun, 28 Mar 2010 07:50:21 -0400 Received: from mail-bw0-f209.google.com ([209.85.218.209]:37062 "EHLO mail-bw0-f209.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754283Ab0C1LuP (ORCPT ); Sun, 28 Mar 2010 07:50:15 -0400 Received: by mail-bw0-f209.google.com with SMTP id 1so2884076bwz.21 for ; Sun, 28 Mar 2010 04:50:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:cc:subject :message-id:mail-followup-to:mime-version:content-type :content-disposition:user-agent; bh=w1r5jXYTcGhkni5pSkG8SwBCQ5eKhToCdsPCl2tiC+g=; b=POZjp3yDkFSKdatpux6Q/FiAXxcEYGRo+0IklVtDRKD2iLQ0zYx8EhhniWT7sD0DNY Zl9nGtXuSDe/x+nFXBvV0z1Q5qBZN3x39JFYEHzC5qisoEJhA6DNCnpfi9xWQ2ffk+hM ZWKxoI7sP//Vt/u2UWRlDjO4GbQmO7oweSFEo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:mail-followup-to:mime-version :content-type:content-disposition:user-agent; b=swa4Nf60nk/8x5oArgRpMWskDbAOlKYcBBuGYNKTS7IUKJgU0H3odKF7+6MjmmyXrY VaR4fr/b+O5I7TAajFYpWFw4NY7m2Rn9s+hkqIPObQBCmtmIA+1hmtkc3pgTD8LvkKH2 KjZglE7G94vm3EjoUNfHJqOJx9mN3rX9y4qhQ= Received: by 10.204.82.227 with SMTP id c35mr3566020bkl.174.1269777013485; Sun, 28 Mar 2010 04:50:13 -0700 (PDT) Received: from bicker ([196.43.68.183]) by mx.google.com with ESMTPS id l1sm27364814bkl.14.2010.03.28.04.50.09 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 28 Mar 2010 04:50:12 -0700 (PDT) Date: Sun, 28 Mar 2010 14:50:05 +0300 From: Dan Carpenter To: Luca Risolia Cc: Mauro Carvalho Chehab , Laurent Pinchart , Alexey Dobriyan , Andreas Mohr , linux-usb@vger.kernel.org, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [patch] video/sn9c102: improve error handling Message-ID: <20100328115005.GW5069@bicker> Mail-Followup-To: Dan Carpenter , Luca Risolia , Mauro Carvalho Chehab , Laurent Pinchart , Alexey Dobriyan , Andreas Mohr , linux-usb@vger.kernel.org, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.18 (2008-05-17) 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.3 (demeter.kernel.org [140.211.167.41]); Sun, 28 Mar 2010 11:50:47 +0000 (UTC) diff --git a/drivers/media/video/sn9c102/sn9c102_core.c b/drivers/media/video/sn9c102/sn9c102_core.c index cbf8087..28e19da 100644 --- a/drivers/media/video/sn9c102/sn9c102_core.c +++ b/drivers/media/video/sn9c102/sn9c102_core.c @@ -2295,7 +2295,7 @@ sn9c102_vidioc_s_ctrl(struct sn9c102_device* cam, void __user * arg) if (copy_from_user(&ctrl, arg, sizeof(ctrl))) return -EFAULT; - for (i = 0; i < ARRAY_SIZE(s->qctrl); i++) + for (i = 0; i < ARRAY_SIZE(s->qctrl); i++) { if (ctrl.id == s->qctrl[i].id) { if (s->qctrl[i].flags & V4L2_CTRL_FLAG_DISABLED) return -EINVAL; @@ -2305,7 +2305,9 @@ sn9c102_vidioc_s_ctrl(struct sn9c102_device* cam, void __user * arg) ctrl.value -= ctrl.value % s->qctrl[i].step; break; } - + } + if (i == ARRAY_SIZE(s->qctrl)) + return -EINVAL; if ((err = s->set_ctrl(cam, &ctrl))) return err;