From patchwork Sat Jan 17 21:42:31 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roel Kluin X-Patchwork-Id: 2966 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n0HLcCFk006057 for ; Sat, 17 Jan 2009 13:38:13 -0800 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751834AbZAQVmc (ORCPT ); Sat, 17 Jan 2009 16:42:32 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751868AbZAQVmc (ORCPT ); Sat, 17 Jan 2009 16:42:32 -0500 Received: from ey-out-2122.google.com ([74.125.78.27]:49959 "EHLO ey-out-2122.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751834AbZAQVmb (ORCPT ); Sat, 17 Jan 2009 16:42:31 -0500 Received: by ey-out-2122.google.com with SMTP id 22so403800eye.37 for ; Sat, 17 Jan 2009 13:42:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:cc:subject:content-type :content-transfer-encoding; bh=xbFhZAZTfoqCV86XO7BtbpoSUeJTx/VlVfe6vIidZl4=; b=kNT+e7u4Q1lYuXigdQ5OEJ5xxi0IxhjxezeWTG6L3jVZEfRQgLdY4rfLHvfz2PTWFE WYzVj3rNUAHCnY1qKSzmgsQ5LGQsYN2lPWS0ZlWqVCYQkpFUBcpQ29rysn+f0JI+ml8D DGW0oCdpU/8Cu7L9bRG7yg0NNXSqfWcHD55IU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :content-type:content-transfer-encoding; b=jYx5gFp0ejCZ5I5B1UELxg2+5Ww9bi/IdzNtpKsLulBd6Kdpv3iHr7VGS9shYKE3S6 Pso2s6edz1my1OrFJnZ+9b64aOqvdPBCUEtRbFDN12OdXJILCjC2e5xqWTTgWI98/lPq InpAmg/EPzGL728BitZlys1wgoA2jwmhH1DOI= Received: by 10.66.233.12 with SMTP id f12mr896535ugh.88.1232228549788; Sat, 17 Jan 2009 13:42:29 -0800 (PST) Received: from ?192.168.1.115? (d133062.upc-d.chello.nl [213.46.133.62]) by mx.google.com with ESMTPS id e23sm5451459ugd.4.2009.01.17.13.42.29 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 17 Jan 2009 13:42:29 -0800 (PST) Message-ID: <497250C7.6030502@gmail.com> Date: Sat, 17 Jan 2009 22:42:31 +0100 From: Roel Kluin User-Agent: Thunderbird 2.0.0.18 (X11/20081105) MIME-Version: 1.0 To: Mauro Carvalho Chehab CC: linux-media@vger.kernel.org, video4linux-list@redhat.com Subject: [PATCH] Bttv: move check on unsigned Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Please review, this patch was not tested. The static function set_tvnorm is called in drivers/media/video/bt8xx/bttv-driver.c: 1355: set_tvnorm(btv, norm); 1868: set_tvnorm(btv, i); 3273: set_tvnorm(btv,btv->tvnorm); in the first two with an unsigned, but bttv->tvnorm is signed. see vi drivers/media/video/bt8xx/bttvp.h +381 since norm is unsigned in set_tvnorm, a negative won't get noticed. so remove the redundant check and move it to the caller. My question is: should we error return like this? Signed-off-by: Roel Kluin --- -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/media/video/bt8xx/bttv-driver.c b/drivers/media/video/bt8xx/bttv-driver.c index c71f394..6f50f90 100644 --- a/drivers/media/video/bt8xx/bttv-driver.c +++ b/drivers/media/video/bt8xx/bttv-driver.c @@ -1290,7 +1290,7 @@ set_tvnorm(struct bttv *btv, unsigned int norm) const struct bttv_tvnorm *tvnorm; v4l2_std_id id; - if (norm < 0 || norm >= BTTV_TVNORMS) + if (norm >= BTTV_TVNORMS) return -EINVAL; tvnorm = &bttv_tvnorms[norm]; @@ -3266,6 +3266,10 @@ static int bttv_open(struct file *file) V4L2_FIELD_SEQ_TB, sizeof(struct bttv_buffer), fh); + if (btv->norm < 0) { + unlock_kernel(); + return -EINVAL; + } set_tvnorm(btv,btv->tvnorm); set_input(btv, btv->input, btv->tvnorm);