From f8a389db502f7b287903b209f925df5570ff5478 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Sat, 14 Apr 2007 15:17:35 -0300 Subject: [PATCH] V4L/DVB (5518): Fix a bug on device detection Thanks to: Thierry MERLE for pointing this Signed-off-by: Mauro Carvalho Chehab --- drivers/media/video/usbvision/usbvision-cards.c | 1 + drivers/media/video/usbvision/usbvision-cards.h | 2 ++ drivers/media/video/usbvision/usbvision-video.c | 4 ++++ 3 files changed, 7 insertions(+) diff --git a/drivers/media/video/usbvision/usbvision-cards.c b/drivers/media/video/usbvision/usbvision-cards.c index c632f12525..edee094cf1 100644 --- a/drivers/media/video/usbvision/usbvision-cards.c +++ b/drivers/media/video/usbvision/usbvision-cards.c @@ -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 */ diff --git a/drivers/media/video/usbvision/usbvision-cards.h b/drivers/media/video/usbvision/usbvision-cards.h index 37d619b1e0..766accc927 100644 --- a/drivers/media/video/usbvision/usbvision-cards.h +++ b/drivers/media/video/usbvision/usbvision-cards.h @@ -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; diff --git a/drivers/media/video/usbvision/usbvision-video.c b/drivers/media/video/usbvision/usbvision-video.c index aa6509391b..df030bf84c 100644 --- a/drivers/media/video/usbvision/usbvision-video.c +++ b/drivers/media/video/usbvision/usbvision-video.c @@ -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); -- 2.39.5