From patchwork Sun Dec 12 17:32:01 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 401242 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 oBCHWUD7012605 for ; Sun, 12 Dec 2010 17:32:30 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753823Ab0LLRc2 (ORCPT ); Sun, 12 Dec 2010 12:32:28 -0500 Received: from smtp-vbr5.xs4all.nl ([194.109.24.25]:1626 "EHLO smtp-vbr5.xs4all.nl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753444Ab0LLRcL (ORCPT ); Sun, 12 Dec 2010 12:32:11 -0500 Received: from localhost.localdomain (159.80-203-19.nextgentel.com [80.203.19.159]) (authenticated bits=0) by smtp-vbr5.xs4all.nl (8.13.8/8.13.8) with ESMTP id oBCHW1MR002236 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sun, 12 Dec 2010 18:32:10 +0100 (CET) (envelope-from hverkuil@xs4all.nl) From: Hans Verkuil To: linux-media@vger.kernel.org Subject: [RFC/PATCH 19/19] v4l2-ctrls: only check def for menu, integer and boolean controls Date: Sun, 12 Dec 2010 18:32:01 +0100 Message-Id: <4afc4287c74b8b2273f51d8f5821c2dc9a5584da.1292174822.git.hverkuil@xs4all.nl> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: References: In-Reply-To: References: X-Virus-Scanned: by XS4ALL Virus Scanner 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 (demeter1.kernel.org [140.211.167.41]); Sun, 12 Dec 2010 17:32:30 +0000 (UTC) diff --git a/drivers/media/video/v4l2-ctrls.c b/drivers/media/video/v4l2-ctrls.c index 6c0fadc..8f81efc 100644 --- a/drivers/media/video/v4l2-ctrls.c +++ b/drivers/media/video/v4l2-ctrls.c @@ -962,13 +962,20 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl, /* Sanity checks */ if (id == 0 || name == NULL || id >= V4L2_CID_PRIVATE_BASE || - def < min || def > max || max < min || + max < min || (type == V4L2_CTRL_TYPE_INTEGER && step == 0) || (type == V4L2_CTRL_TYPE_MENU && qmenu == NULL) || (type == V4L2_CTRL_TYPE_STRING && max == 0)) { handler_set_err(hdl, -ERANGE); return NULL; } + if ((type == V4L2_CTRL_TYPE_INTEGER || + type == V4L2_CTRL_TYPE_MENU || + type == V4L2_CTRL_TYPE_BOOLEAN) && + (def < min || def > max)) { + handler_set_err(hdl, -ERANGE); + return NULL; + } if (type == V4L2_CTRL_TYPE_BUTTON) flags |= V4L2_CTRL_FLAG_WRITE_ONLY;