From patchwork Sun Mar 28 11:49:45 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 88759 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 o2SBoREu003138 for ; Sun, 28 Mar 2010 11:50:27 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754519Ab0C1Lt5 (ORCPT ); Sun, 28 Mar 2010 07:49:57 -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 S1754508Ab0C1Lty (ORCPT ); Sun, 28 Mar 2010 07:49:54 -0400 Received: by mail-bw0-f209.google.com with SMTP id 1so2884076bwz.21 for ; Sun, 28 Mar 2010 04:49:53 -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=QTMXqNYUf7P5NzZs6z1nSHK0sWLBXPUT2vRT3b8tohw=; b=QEjAzqq5khUQ3ClchsTtuTJ0ZzF6ezLlaTFQT2gDQrtbtT/qZH4UggR+4bE2wrDcs8 x9ofbJxcdOwbELfEScLVeJ0bjfC8NUW9VwQRdHhp+Rv7W1Tx47jpUn3jW+m+OocNlLQ7 FoOT9nbJGY3265YSasigZzC1ZbBsp761mC4a8= 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=u7+UtzRKXdIxvfBbmdSnhS71S8n2vIgTAkxDjmpHrOO6JJJihbgLp5HE40UfUs0J0S BQR2tL2Nm65qEnXqqsqmVQJmSTn3jwx1Go/sM0xyiu2G4vJ4tFbhhun23AIp086CW7Rc LF5zbpT2orkRl068jGfp3iLVWW4/b35/NfBdU= Received: by 10.204.153.213 with SMTP id l21mr1157382bkw.58.1269776993318; Sun, 28 Mar 2010 04:49:53 -0700 (PDT) Received: from bicker ([196.43.68.183]) by mx.google.com with ESMTPS id 24sm27354824bkr.12.2010.03.28.04.49.49 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 28 Mar 2010 04:49:52 -0700 (PDT) Date: Sun, 28 Mar 2010 14:49:45 +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/et61x251: improve error handling Message-ID: <20100328114945.GV5069@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:27 +0000 (UTC) diff --git a/drivers/media/video/et61x251/et61x251_core.c b/drivers/media/video/et61x251/et61x251_core.c index e6c23d5..a5cfc76 100644 --- a/drivers/media/video/et61x251/et61x251_core.c +++ b/drivers/media/video/et61x251/et61x251_core.c @@ -1713,7 +1713,7 @@ et61x251_vidioc_s_ctrl(struct et61x251_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; @@ -1723,7 +1723,9 @@ et61x251_vidioc_s_ctrl(struct et61x251_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;