]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
V4L: bttv: Prevent NULL pointer dereference in radio_open
authorJean Delvare <khali@linux-fr.org>
Fri, 10 Oct 2008 12:41:38 +0000 (08:41 -0400)
committerGreg Kroah-Hartman <gregkh@suse.de>
Wed, 22 Oct 2008 21:13:20 +0000 (14:13 -0700)
(cherry picked from commit c37396c19403e249f12626187d51e92c915f2bc9)

Fix the following crash in the bttv driver:

BUG: unable to handle kernel NULL pointer dereference at 000000000000036c
IP: [<ffffffffa037860a>] radio_open+0x3a/0x170 [bttv]

This happens because radio_open assumes that all present bttv devices
have a radio function. If a bttv device without radio and one with
radio are installed on the same system, and the one without radio is
registered first, then radio_open checks for the radio device number
of a bttv device that has no radio function, and this breaks. All we
have to do to fix it is to skip bttv devices without a radio function.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Signed-off-by: Michael Krufky <mkrufky@linuxtv.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/media/video/bt8xx/bttv-driver.c

index 0165aac533bf1d98eb7d7c9f2a0c4cf71f61d11e..7bcd328533c491b63af3802ec4417cd031b4fd9d 100644 (file)
@@ -3428,7 +3428,7 @@ static int radio_open(struct inode *inode, struct file *file)
        dprintk("bttv: open minor=%d\n",minor);
 
        for (i = 0; i < bttv_num; i++) {
-               if (bttvs[i].radio_dev->minor == minor) {
+               if (bttvs[i].radio_dev && bttvs[i].radio_dev->minor == minor) {
                        btv = &bttvs[i];
                        break;
                }