Commit a71eddf2 authored by Vladis Dronov's avatar Vladis Dronov Committed by Ben Hutchings

usbvision: fix crash on detecting device with invalid configuration

commit fa52bd50 upstream.

The usbvision driver crashes when a specially crafted usb device with invalid
number of interfaces or endpoints is detected. This fix adds checks that the
device has proper configuration expected by the driver.
Reported-by: default avatarRalf Spenneberg <ralf@spenneberg.net>
Signed-off-by: default avatarVladis Dronov <vdronov@redhat.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
[bwh: Backport to 3.2: adjust filename]
Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
parent ae64b688
...@@ -1511,9 +1511,23 @@ static int __devinit usbvision_probe(struct usb_interface *intf, ...@@ -1511,9 +1511,23 @@ static int __devinit usbvision_probe(struct usb_interface *intf,
if (usbvision_device_data[model].interface >= 0) if (usbvision_device_data[model].interface >= 0)
interface = &dev->actconfig->interface[usbvision_device_data[model].interface]->altsetting[0]; interface = &dev->actconfig->interface[usbvision_device_data[model].interface]->altsetting[0];
else else if (ifnum < dev->actconfig->desc.bNumInterfaces)
interface = &dev->actconfig->interface[ifnum]->altsetting[0]; interface = &dev->actconfig->interface[ifnum]->altsetting[0];
else {
dev_err(&intf->dev, "interface %d is invalid, max is %d\n",
ifnum, dev->actconfig->desc.bNumInterfaces - 1);
ret = -ENODEV;
goto err_usb;
}
if (interface->desc.bNumEndpoints < 2) {
dev_err(&intf->dev, "interface %d has %d endpoints, but must"
" have minimum 2\n", ifnum, interface->desc.bNumEndpoints);
ret = -ENODEV;
goto err_usb;
}
endpoint = &interface->endpoint[1].desc; endpoint = &interface->endpoint[1].desc;
if (!usb_endpoint_xfer_isoc(endpoint)) { if (!usb_endpoint_xfer_isoc(endpoint)) {
dev_err(&intf->dev, "%s: interface %d. has non-ISO endpoint!\n", dev_err(&intf->dev, "%s: interface %d. has non-ISO endpoint!\n",
__func__, ifnum); __func__, ifnum);
......
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