[media] ivtv: avoid going past input/audio array
authorMauro Carvalho Chehab <mchehab@osg.samsung.com>
Wed, 11 Nov 2015 11:27:42 +0000 (09:27 -0200)
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>
Mon, 16 Nov 2015 09:38:04 +0000 (07:38 -0200)
As reported by smatch:
drivers/media/pci/ivtv/ivtv-driver.c:832 ivtv_init_struct2() error: buffer overflow 'itv->card->video_inputs' 6 <= 6

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
drivers/media/pci/ivtv/ivtv-driver.c

index c2e60b4f292d1d8d9791b5c44b0fa76c0ffd854b..2bb10cd9ecfd6ac21449dbd9d3255f19fa1adf3c 100644 (file)
@@ -826,7 +826,7 @@ static void ivtv_init_struct2(struct ivtv *itv)
                                IVTV_CARD_INPUT_VID_TUNER)
                        break;
        }
-       if (i == itv->nof_inputs)
+       if (i >= itv->nof_inputs)
                i = 0;
        itv->active_input = i;
        itv->audio_input = itv->card->video_inputs[i].audio_index;