From patchwork Mon Oct 4 19:28:01 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 230031 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 o94JSNP4004125 for ; Mon, 4 Oct 2010 19:28:23 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932212Ab0JDT2T (ORCPT ); Mon, 4 Oct 2010 15:28:19 -0400 Received: from mail-wy0-f174.google.com ([74.125.82.174]:38052 "EHLO mail-wy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755689Ab0JDT2T (ORCPT ); Mon, 4 Oct 2010 15:28:19 -0400 Received: by wyb28 with SMTP id 28so5271119wyb.19 for ; Mon, 04 Oct 2010 12:28:17 -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:mime-version:content-type:content-disposition:user-agent; bh=J+t+XegQeNsfw46zVs5GT9cUGQ2v/4AN4rmIGmZCJFM=; b=ShgInouCaEcKwqfwkJmS5pJQZpcJLKr5hG0Z1pUg0rKdG9NIjszmrFvZF7ThD9gTez pJLGAOL6rp3IOYv9+xl78kt7pJiOBEM/99uP5eA0lUMuC2S0rchv5PCGOdLXx2mwJ6hw kTLYnUTgdM+EfnUzI5QCeW0/QwhkU1Ah0HQQY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:mime-version:content-type :content-disposition:user-agent; b=qS5olTqhrEcW3fd+ZJU4pgLZS9p8mEvzgr5mJeq2i5arIFlN6ETKsPTlO6eZa1eQtX arGANb8yS75CSR1q6IwIoAqjUmtbFyIZ2stvs55KowvwN18HxLG3yieQqQJsyu73TEhw k/9tm3RaGw//OAAdUplXubKbdZo+R+/fCbMwo= Received: by 10.227.72.139 with SMTP id m11mr8888420wbj.30.1286220497813; Mon, 04 Oct 2010 12:28:17 -0700 (PDT) Received: from bicker (h3f08.n1.ips.mtn.co.ug [41.210.191.8]) by mx.google.com with ESMTPS id r18sm3255358weo.0.2010.10.04.12.28.11 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 04 Oct 2010 12:28:15 -0700 (PDT) Date: Mon, 4 Oct 2010 21:28:01 +0200 From: Dan Carpenter To: Mauro Carvalho Chehab Cc: Laurent Pinchart , Hans Verkuil , Herton Ronaldo Krzesinski , Sean Young , linux-media@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [patch] V4L/DVB: saa7134: add test after for loop Message-ID: <20101004192801.GG5692@bicker> 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 (demeter1.kernel.org [140.211.167.41]); Mon, 04 Oct 2010 19:28:36 +0000 (UTC) diff --git a/drivers/media/video/saa7134/saa7134-video.c b/drivers/media/video/saa7134/saa7134-video.c index 45f0ac8..24c3a78 100644 --- a/drivers/media/video/saa7134/saa7134-video.c +++ b/drivers/media/video/saa7134/saa7134-video.c @@ -1871,9 +1871,12 @@ int saa7134_s_std_internal(struct saa7134_dev *dev, struct saa7134_fh *fh, v4l2_ else fixup = V4L2_STD_SECAM; } - for (i = 0; i < TVNORMS; i++) + for (i = 0; i < TVNORMS; i++) { if (fixup == tvnorms[i].id) break; + } + if (i == TVNORMS) + return -EINVAL; } *id = tvnorms[i].id; @@ -1997,9 +2000,12 @@ static int saa7134_g_tuner(struct file *file, void *priv, if (0 != t->index) return -EINVAL; memset(t, 0, sizeof(*t)); - for (n = 0; n < SAA7134_INPUT_MAX; n++) + for (n = 0; n < SAA7134_INPUT_MAX; n++) { if (card_in(dev, n).tv) break; + } + if (n == SAA7134_INPUT_MAX) + return -EINVAL; if (NULL != card_in(dev, n).name) { strcpy(t->name, "Television"); t->type = V4L2_TUNER_ANALOG_TV;