Skip to content

Commit 0d8c1f1

Browse files
nefigtutgregkh
authored andcommitted
usbvision: fix crash on detecting device with invalid configuration
commit fa52bd506f274b7619955917abfde355e3d19ffe 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: Ralf Spenneberg <ralf@spenneberg.net> Signed-off-by: Vladis Dronov <vdronov@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 440e9a2 commit 0d8c1f1

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

drivers/media/usb/usbvision/usbvision-video.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1463,9 +1463,23 @@ static int usbvision_probe(struct usb_interface *intf,
14631463

14641464
if (usbvision_device_data[model].interface >= 0)
14651465
interface = &dev->actconfig->interface[usbvision_device_data[model].interface]->altsetting[0];
1466-
else
1466+
else if (ifnum < dev->actconfig->desc.bNumInterfaces)
14671467
interface = &dev->actconfig->interface[ifnum]->altsetting[0];
1468+
else {
1469+
dev_err(&intf->dev, "interface %d is invalid, max is %d\n",
1470+
ifnum, dev->actconfig->desc.bNumInterfaces - 1);
1471+
ret = -ENODEV;
1472+
goto err_usb;
1473+
}
1474+
1475+
if (interface->desc.bNumEndpoints < 2) {
1476+
dev_err(&intf->dev, "interface %d has %d endpoints, but must"
1477+
" have minimum 2\n", ifnum, interface->desc.bNumEndpoints);
1478+
ret = -ENODEV;
1479+
goto err_usb;
1480+
}
14681481
endpoint = &interface->endpoint[1].desc;
1482+
14691483
if (!usb_endpoint_xfer_isoc(endpoint)) {
14701484
dev_err(&intf->dev, "%s: interface %d. has non-ISO endpoint!\n",
14711485
__func__, ifnum);

0 commit comments

Comments
 (0)