Skip to content

Commit 179295c

Browse files
jhovoldgregkh
authored andcommitted
USB: iowarrior: fix NULL-deref at probe
commit b7321e81fc369abe353cf094d4f0dc2fe11ab95f upstream. Make sure to check for the required interrupt-in endpoint to avoid dereferencing a NULL-pointer should a malicious device lack such an endpoint. Note that a fairly recent change purported to fix this issue, but added an insufficient test on the number of endpoints only, a test which can now be removed. Fixes: 4ec0ef3a8212 ("USB: iowarrior: fix oops with malicious USB descriptors") Fixes: 946b960 ("USB: add driver for iowarrior devices.") Signed-off-by: Johan Hovold <johan@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 54f11a9 commit 179295c

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

drivers/usb/misc/iowarrior.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -787,12 +787,6 @@ static int iowarrior_probe(struct usb_interface *interface,
787787
iface_desc = interface->cur_altsetting;
788788
dev->product_id = le16_to_cpu(udev->descriptor.idProduct);
789789

790-
if (iface_desc->desc.bNumEndpoints < 1) {
791-
dev_err(&interface->dev, "Invalid number of endpoints\n");
792-
retval = -EINVAL;
793-
goto error;
794-
}
795-
796790
/* set up the endpoint information */
797791
for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) {
798792
endpoint = &iface_desc->endpoint[i].desc;
@@ -803,6 +797,13 @@ static int iowarrior_probe(struct usb_interface *interface,
803797
/* this one will match for the IOWarrior56 only */
804798
dev->int_out_endpoint = endpoint;
805799
}
800+
801+
if (!dev->int_in_endpoint) {
802+
dev_err(&interface->dev, "no interrupt-in endpoint found\n");
803+
retval = -ENODEV;
804+
goto error;
805+
}
806+
806807
/* we have to check the report_size often, so remember it in the endianness suitable for our machine */
807808
dev->report_size = usb_endpoint_maxp(dev->int_in_endpoint);
808809
if ((dev->interface->cur_altsetting->desc.bInterfaceNumber == 0) &&

0 commit comments

Comments
 (0)