From: Dan Carpenter Date: Mon, 4 Oct 2010 19:28:01 +0000 (-0300) Subject: [media] saa7134: add test after for loop X-Git-Tag: MMI-PSA29.97-13-9~21911^2~193 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=06e6588edfb2be6fb3e544097c07274bd7b64084;p=GitHub%2FMotorolaMobilityLLC%2Fkernel-slsi.git [media] saa7134: add test after for loop Add a check after the for loops to see if we found what we were looking for or if we reached the end of the list. Signed-off-by: Dan Carpenter Signed-off-by: Mauro Carvalho Chehab --- diff --git a/drivers/media/video/saa7134/saa7134-video.c b/drivers/media/video/saa7134/saa7134-video.c index fae5e97a3eb2..f0b1573137f4 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;