aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <m.chehab@samsung.com>2014-07-27 15:27:28 -0400
committerMauro Carvalho Chehab <m.chehab@samsung.com>2014-07-27 15:54:04 -0400
commitdcb78ac761488f59ac16c2e76534c567017ef57b (patch)
treef0ebe91d3b6379ce04d9aee06cfc78183428b143 /drivers/media
parent139d28826b8e2bc7a9232fde0d2f14812914f501 (diff)
[media] cx231xx: Don't let an interface number to go past the array
On some newer boards, like HVR-930C HD, the information at the PCB tables are sometimes higher than the ones actually available on the device. That causes the probing code to go past the interfaces array. Add checks to the interface number before going past the array. Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/usb/cx231xx/cx231xx-cards.c42
1 files changed, 30 insertions, 12 deletions
diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c b/drivers/media/usb/cx231xx/cx231xx-cards.c
index 6d785db96d99..38d8510f93c2 100644
--- a/drivers/media/usb/cx231xx/cx231xx-cards.c
+++ b/drivers/media/usb/cx231xx/cx231xx-cards.c
@@ -1135,6 +1135,7 @@ static int cx231xx_usb_probe(struct usb_interface *interface,
1135 int nr = 0, ifnum; 1135 int nr = 0, ifnum;
1136 int i, isoc_pipe = 0; 1136 int i, isoc_pipe = 0;
1137 char *speed; 1137 char *speed;
1138 u8 idx;
1138 struct usb_interface_assoc_descriptor *assoc_desc; 1139 struct usb_interface_assoc_descriptor *assoc_desc;
1139 1140
1140 ifnum = interface->altsetting[0].desc.bInterfaceNumber; 1141 ifnum = interface->altsetting[0].desc.bInterfaceNumber;
@@ -1254,8 +1255,13 @@ static int cx231xx_usb_probe(struct usb_interface *interface,
1254 goto err_init; 1255 goto err_init;
1255 1256
1256 /* compute alternate max packet sizes for video */ 1257 /* compute alternate max packet sizes for video */
1257 uif = udev->actconfig->interface[dev->current_pcb_config. 1258 idx = dev->current_pcb_config.hs_config_info[0].interface_info.video_index + 1;
1258 hs_config_info[0].interface_info.video_index + 1]; 1259 if (idx >= dev->max_iad_interface_count) {
1260 cx231xx_errdev("Video PCB interface #%d doesn't exist\n", idx);
1261 retval = -ENODEV;
1262 goto err_init;
1263 }
1264 uif = udev->actconfig->interface[idx];
1259 1265
1260 dev->video_mode.end_point_addr = uif->altsetting[0]. 1266 dev->video_mode.end_point_addr = uif->altsetting[0].
1261 endpoint[isoc_pipe].desc.bEndpointAddress; 1267 endpoint[isoc_pipe].desc.bEndpointAddress;
@@ -1283,9 +1289,14 @@ static int cx231xx_usb_probe(struct usb_interface *interface,
1283 } 1289 }
1284 1290
1285 /* compute alternate max packet sizes for vbi */ 1291 /* compute alternate max packet sizes for vbi */
1286 uif = udev->actconfig->interface[dev->current_pcb_config. 1292
1287 hs_config_info[0].interface_info. 1293 idx = dev->current_pcb_config.hs_config_info[0].interface_info.vanc_index + 1;
1288 vanc_index + 1]; 1294 if (idx >= dev->max_iad_interface_count) {
1295 cx231xx_errdev("VBI PCB interface #%d doesn't exist\n", idx);
1296 retval = -ENODEV;
1297 goto err_vbi_alt;
1298 }
1299 uif = udev->actconfig->interface[idx];
1289 1300
1290 dev->vbi_mode.end_point_addr = 1301 dev->vbi_mode.end_point_addr =
1291 uif->altsetting[0].endpoint[isoc_pipe].desc. 1302 uif->altsetting[0].endpoint[isoc_pipe].desc.
@@ -1315,9 +1326,13 @@ static int cx231xx_usb_probe(struct usb_interface *interface,
1315 } 1326 }
1316 1327
1317 /* compute alternate max packet sizes for sliced CC */ 1328 /* compute alternate max packet sizes for sliced CC */
1318 uif = udev->actconfig->interface[dev->current_pcb_config. 1329 idx = dev->current_pcb_config.hs_config_info[0].interface_info.hanc_index + 1;
1319 hs_config_info[0].interface_info. 1330 if (idx >= dev->max_iad_interface_count) {
1320 hanc_index + 1]; 1331 cx231xx_errdev("Sliced CC PCB interface #%d doesn't exist\n", idx);
1332 retval = -ENODEV;
1333 goto err_sliced_cc_alt;
1334 }
1335 uif = udev->actconfig->interface[idx];
1321 1336
1322 dev->sliced_cc_mode.end_point_addr = 1337 dev->sliced_cc_mode.end_point_addr =
1323 uif->altsetting[0].endpoint[isoc_pipe].desc. 1338 uif->altsetting[0].endpoint[isoc_pipe].desc.
@@ -1347,10 +1362,13 @@ static int cx231xx_usb_probe(struct usb_interface *interface,
1347 1362
1348 if (dev->current_pcb_config.ts1_source != 0xff) { 1363 if (dev->current_pcb_config.ts1_source != 0xff) {
1349 /* compute alternate max packet sizes for TS1 */ 1364 /* compute alternate max packet sizes for TS1 */
1350 uif = udev->actconfig->interface[dev->current_pcb_config. 1365 idx = dev->current_pcb_config.hs_config_info[0].interface_info.ts1_index + 1;
1351 hs_config_info[0]. 1366 if (idx >= dev->max_iad_interface_count) {
1352 interface_info. 1367 cx231xx_errdev("TS1 PCB interface #%d doesn't exist\n", idx);
1353 ts1_index + 1]; 1368 retval = -ENODEV;
1369 goto err_ts1_alt;
1370 }
1371 uif = udev->actconfig->interface[idx];
1354 1372
1355 dev->ts1_mode.end_point_addr = 1373 dev->ts1_mode.end_point_addr =
1356 uif->altsetting[0].endpoint[isoc_pipe]. 1374 uif->altsetting[0].endpoint[isoc_pipe].