From patchwork Sun Mar 28 11:49:20 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 88757 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 o2SBnwCq002950 for ; Sun, 28 Mar 2010 11:49:58 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754163Ab0C1Ltc (ORCPT ); Sun, 28 Mar 2010 07:49:32 -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 S1753444Ab0C1Lta (ORCPT ); Sun, 28 Mar 2010 07:49:30 -0400 Received: by bwz1 with SMTP id 1so2884076bwz.21 for ; Sun, 28 Mar 2010 04:49:28 -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=g+WAZGZxKh5hwquhUvInRBBNZsqcSE5DV8XumbDDYiY=; b=miByvOWl9gH0KfMSZX8KsLuLsXxSPl75TguVodPiY8Ez/Vzdqs3dJ69a+NypbXoeGT LCOLBu0d3J3bF3UUYb53gV2QrldhDQPxkXM7jV0RYvZIL1dnQ34xZslwj6mI+YnPlctm hZTIMbdW8RRJ3WF964AM69iOBjmDzql/NG1ek= 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=hTHWgs5xKRI2ii/V5XiRWGaj+TutY5fHIS8CtToveLcTxYTiYMHiuR/BgX8N6Z3tBk uWt6smc3YRQdYuSmiOl6w0ssBLQUv9GB36XM0prVcUgyTy6xnFYmts9h6ZTicp2AeKHD lfZm4DR6VR12CxwNxwGNTW71sGfG9EYywna2o= Received: by 10.204.36.73 with SMTP id s9mr5045404bkd.39.1269776968582; Sun, 28 Mar 2010 04:49:28 -0700 (PDT) Received: from bicker ([196.43.68.183]) by mx.google.com with ESMTPS id d5sm27336973bkd.19.2010.03.28.04.49.24 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 28 Mar 2010 04:49:27 -0700 (PDT) Date: Sun, 28 Mar 2010 14:49:20 +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/zc0301: improve error handling Message-ID: <20100328114920.GU5069@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:49:58 +0000 (UTC) diff --git a/drivers/media/video/zc0301/zc0301_core.c b/drivers/media/video/zc0301/zc0301_core.c index e44e4b5..bb51cfb 100644 --- a/drivers/media/video/zc0301/zc0301_core.c +++ b/drivers/media/video/zc0301/zc0301_core.c @@ -1153,7 +1153,7 @@ zc0301_vidioc_s_ctrl(struct zc0301_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; @@ -1163,7 +1163,9 @@ zc0301_vidioc_s_ctrl(struct zc0301_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;