Commit dcb78ac7 authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab

[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: default avatarMauro Carvalho Chehab <m.chehab@samsung.com>
parent 139d2882
...@@ -1135,6 +1135,7 @@ static int cx231xx_usb_probe(struct usb_interface *interface, ...@@ -1135,6 +1135,7 @@ static int cx231xx_usb_probe(struct usb_interface *interface,
int nr = 0, ifnum; int nr = 0, ifnum;
int i, isoc_pipe = 0; int i, isoc_pipe = 0;
char *speed; char *speed;
u8 idx;
struct usb_interface_assoc_descriptor *assoc_desc; struct usb_interface_assoc_descriptor *assoc_desc;
ifnum = interface->altsetting[0].desc.bInterfaceNumber; ifnum = interface->altsetting[0].desc.bInterfaceNumber;
...@@ -1254,8 +1255,13 @@ static int cx231xx_usb_probe(struct usb_interface *interface, ...@@ -1254,8 +1255,13 @@ static int cx231xx_usb_probe(struct usb_interface *interface,
goto err_init; goto err_init;
/* compute alternate max packet sizes for video */ /* compute alternate max packet sizes for video */
uif = udev->actconfig->interface[dev->current_pcb_config. idx = dev->current_pcb_config.hs_config_info[0].interface_info.video_index + 1;
hs_config_info[0].interface_info.video_index + 1]; if (idx >= dev->max_iad_interface_count) {
cx231xx_errdev("Video PCB interface #%d doesn't exist\n", idx);
retval = -ENODEV;
goto err_init;
}
uif = udev->actconfig->interface[idx];
dev->video_mode.end_point_addr = uif->altsetting[0]. dev->video_mode.end_point_addr = uif->altsetting[0].
endpoint[isoc_pipe].desc.bEndpointAddress; endpoint[isoc_pipe].desc.bEndpointAddress;
...@@ -1283,9 +1289,14 @@ static int cx231xx_usb_probe(struct usb_interface *interface, ...@@ -1283,9 +1289,14 @@ static int cx231xx_usb_probe(struct usb_interface *interface,
} }
/* compute alternate max packet sizes for vbi */ /* compute alternate max packet sizes for vbi */
uif = udev->actconfig->interface[dev->current_pcb_config.
hs_config_info[0].interface_info. idx = dev->current_pcb_config.hs_config_info[0].interface_info.vanc_index + 1;
vanc_index + 1]; if (idx >= dev->max_iad_interface_count) {
cx231xx_errdev("VBI PCB interface #%d doesn't exist\n", idx);
retval = -ENODEV;
goto err_vbi_alt;
}
uif = udev->actconfig->interface[idx];
dev->vbi_mode.end_point_addr = dev->vbi_mode.end_point_addr =
uif->altsetting[0].endpoint[isoc_pipe].desc. uif->altsetting[0].endpoint[isoc_pipe].desc.
...@@ -1315,9 +1326,13 @@ static int cx231xx_usb_probe(struct usb_interface *interface, ...@@ -1315,9 +1326,13 @@ static int cx231xx_usb_probe(struct usb_interface *interface,
} }
/* compute alternate max packet sizes for sliced CC */ /* compute alternate max packet sizes for sliced CC */
uif = udev->actconfig->interface[dev->current_pcb_config. idx = dev->current_pcb_config.hs_config_info[0].interface_info.hanc_index + 1;
hs_config_info[0].interface_info. if (idx >= dev->max_iad_interface_count) {
hanc_index + 1]; cx231xx_errdev("Sliced CC PCB interface #%d doesn't exist\n", idx);
retval = -ENODEV;
goto err_sliced_cc_alt;
}
uif = udev->actconfig->interface[idx];
dev->sliced_cc_mode.end_point_addr = dev->sliced_cc_mode.end_point_addr =
uif->altsetting[0].endpoint[isoc_pipe].desc. uif->altsetting[0].endpoint[isoc_pipe].desc.
...@@ -1347,10 +1362,13 @@ static int cx231xx_usb_probe(struct usb_interface *interface, ...@@ -1347,10 +1362,13 @@ static int cx231xx_usb_probe(struct usb_interface *interface,
if (dev->current_pcb_config.ts1_source != 0xff) { if (dev->current_pcb_config.ts1_source != 0xff) {
/* compute alternate max packet sizes for TS1 */ /* compute alternate max packet sizes for TS1 */
uif = udev->actconfig->interface[dev->current_pcb_config. idx = dev->current_pcb_config.hs_config_info[0].interface_info.ts1_index + 1;
hs_config_info[0]. if (idx >= dev->max_iad_interface_count) {
interface_info. cx231xx_errdev("TS1 PCB interface #%d doesn't exist\n", idx);
ts1_index + 1]; retval = -ENODEV;
goto err_ts1_alt;
}
uif = udev->actconfig->interface[idx];
dev->ts1_mode.end_point_addr = dev->ts1_mode.end_point_addr =
uif->altsetting[0].endpoint[isoc_pipe]. uif->altsetting[0].endpoint[isoc_pipe].
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment