V4L/DVB (7891): cx18/ivtv: fix open() kernel oops
authorAndy Walls <awalls@radix.net>
Mon, 12 May 2008 18:01:27 +0000 (15:01 -0300)
committerMauro Carvalho Chehab <mchehab@infradead.org>
Wed, 14 May 2008 05:56:45 +0000 (02:56 -0300)
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>
drivers/media/video/cx18/cx18-fileops.c
drivers/media/video/ivtv/ivtv-fileops.c

index 91eff6e671a77d037f99ef229a097c6a2db35fc4..0b3141db174bbf4473b158d81882af7c2e8415b0 100644 (file)
@@ -662,6 +662,8 @@ int cx18_v4l2_open(struct inode *inode, struct file *filp)
        for (x = 0; cx == NULL && x < cx18_cards_active; x++) {
                /* find out which stream this open was on */
                for (y = 0; y < CX18_MAX_STREAMS; y++) {
+                       if (cx18_cards[x] == NULL)
+                               continue;
                        s = &cx18_cards[x]->streams[y];
                        if (s->v4l2dev && s->v4l2dev->minor == minor) {
                                cx = cx18_cards[x];
index 2b74b0ab147788c7942d5af34dfe1beeb954f904..f2fa434b677b88673ef4e7335b10f2f92f02d095 100644 (file)
@@ -987,6 +987,8 @@ int ivtv_v4l2_open(struct inode *inode, struct file *filp)
        /* Find which card this open was on */
        spin_lock(&ivtv_cards_lock);
        for (x = 0; itv == NULL && x < ivtv_cards_active; x++) {
+               if (ivtv_cards[x] == NULL)
+                       continue;
                /* find out which stream this open was on */
                for (y = 0; y < IVTV_MAX_STREAMS; y++) {
                        s = &ivtv_cards[x]->streams[y];