V4L/DVB (5518): Fix a bug on device detection
authorMauro Carvalho Chehab <mchehab@infradead.org>
Sat, 14 Apr 2007 18:17:35 +0000 (15:17 -0300)
committerMauro Carvalho Chehab <mchehab@infradead.org>
Fri, 27 Apr 2007 18:45:35 +0000 (15:45 -0300)
Thanks to: Thierry MERLE <thierry.merle@free.fr> for pointing this

Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
drivers/media/video/usbvision/usbvision-cards.c
drivers/media/video/usbvision/usbvision-cards.h
drivers/media/video/usbvision/usbvision-video.c

index c632f125252c4d37998182e43c48947700956571..edee094cf15de35ea92dcf4542c31bb7e1257d42 100644 (file)
@@ -1027,6 +1027,7 @@ struct usbvision_device_data_st  usbvision_device_data[] = {
                .ModelString   = "Hauppauge WinTv-USB",
        },
 };
+const int usbvision_device_data_size=ARRAY_SIZE(usbvision_device_data);
 
 /* Supported Devices */
 
index 37d619b1e038195726c455b694e7eb2691e656e5..766accc927ef6bd74341c53bdc960c63da207f2f 100644 (file)
@@ -63,3 +63,5 @@
 #define PINNA_LINX_VD_IN_CAB_PAL                 62
 #define PINNA_PCTV_BUNGEE_PAL_FM                 63
 #define HPG_WINTV                                64
+
+extern const int usbvision_device_data_size;
index aa6509391bf9c4d2be2b2a3642868de8a04f77c3..df030bf84c004c4eba2f9aff897e518845373a4d 100644 (file)
@@ -1792,6 +1792,10 @@ static int __devinit usbvision_probe(struct usb_interface *intf,
                                dev->descriptor.idProduct, ifnum);
 
        model = devid->driver_info;
+       if ( (model<0) || (model>=usbvision_device_data_size) ) {
+               printk(KERN_INFO "model out of bounds %d\n",model);
+               return -ENODEV;
+       }
        printk(KERN_INFO "%s: %s found\n", __FUNCTION__,
                                usbvision_device_data[model].ModelString);