V4L/DVB (7891): cx18/ivtv: fix open() kernel oops

Upon error conditions in cx18/ivtv_probe(), the code at the 'err:' label
leaves a NULL entry in cx18/ivtv_cards[]. This can cause a NULL pointer
de-reference in cx18/ivtv_v4l2_open() which is fixed by this patch.

Signed-off-by: Andy Walls <awalls@radix.net>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>

authored by Andy Walls and committed by Mauro Carvalho Chehab 07c87a83 cba627a5

+4
+2
drivers/media/video/cx18/cx18-fileops.c
··· 662 for (x = 0; cx == NULL && x < cx18_cards_active; x++) { 663 /* find out which stream this open was on */ 664 for (y = 0; y < CX18_MAX_STREAMS; y++) { 665 s = &cx18_cards[x]->streams[y]; 666 if (s->v4l2dev && s->v4l2dev->minor == minor) { 667 cx = cx18_cards[x];
··· 662 for (x = 0; cx == NULL && x < cx18_cards_active; x++) { 663 /* find out which stream this open was on */ 664 for (y = 0; y < CX18_MAX_STREAMS; y++) { 665 + if (cx18_cards[x] == NULL) 666 + continue; 667 s = &cx18_cards[x]->streams[y]; 668 if (s->v4l2dev && s->v4l2dev->minor == minor) { 669 cx = cx18_cards[x];
+2
drivers/media/video/ivtv/ivtv-fileops.c
··· 987 /* Find which card this open was on */ 988 spin_lock(&ivtv_cards_lock); 989 for (x = 0; itv == NULL && x < ivtv_cards_active; x++) { 990 /* find out which stream this open was on */ 991 for (y = 0; y < IVTV_MAX_STREAMS; y++) { 992 s = &ivtv_cards[x]->streams[y];
··· 987 /* Find which card this open was on */ 988 spin_lock(&ivtv_cards_lock); 989 for (x = 0; itv == NULL && x < ivtv_cards_active; x++) { 990 + if (ivtv_cards[x] == NULL) 991 + continue; 992 /* find out which stream this open was on */ 993 for (y = 0; y < IVTV_MAX_STREAMS; y++) { 994 s = &ivtv_cards[x]->streams[y];