Skip to content

Commit 040e3ab

Browse files
committed
Merge tag 'usb-4.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
Pull USB fixes from Greg KH: "Here is a USB fix for the reported issue with commit 69bec72 ("USB: core: let USB device know device node") as well as some other issues that have been reported so far with this merge window" * tag 'usb-4.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: USB: uas: Reduce can_queue to MAX_CMNDS USB: cdc-acm: more sanity checking USB: usb_driver_claim_interface: add sanity checking usb/core: usb_alloc_dev(): fix setting of ->portnum USB: iowarrior: fix oops with malicious USB descriptors
2 parents f7813ad + 55ff8cf commit 040e3ab

File tree

5 files changed

+18
-4
lines changed

5 files changed

+18
-4
lines changed

drivers/usb/class/cdc-acm.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,6 +1179,9 @@ static int acm_probe(struct usb_interface *intf,
11791179
if (quirks == NO_UNION_NORMAL) {
11801180
data_interface = usb_ifnum_to_if(usb_dev, 1);
11811181
control_interface = usb_ifnum_to_if(usb_dev, 0);
1182+
/* we would crash */
1183+
if (!data_interface || !control_interface)
1184+
return -ENODEV;
11821185
goto skip_normal_probe;
11831186
}
11841187

drivers/usb/core/driver.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,11 +502,15 @@ static int usb_unbind_interface(struct device *dev)
502502
int usb_driver_claim_interface(struct usb_driver *driver,
503503
struct usb_interface *iface, void *priv)
504504
{
505-
struct device *dev = &iface->dev;
505+
struct device *dev;
506506
struct usb_device *udev;
507507
int retval = 0;
508508
int lpm_disable_error;
509509

510+
if (!iface)
511+
return -ENODEV;
512+
513+
dev = &iface->dev;
510514
if (dev->driver)
511515
return -EBUSY;
512516

drivers/usb/core/usb.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,7 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent,
424424
struct usb_device *dev;
425425
struct usb_hcd *usb_hcd = bus_to_hcd(bus);
426426
unsigned root_hub = 0;
427+
unsigned raw_port = port1;
427428

428429
dev = kzalloc(sizeof(*dev), GFP_KERNEL);
429430
if (!dev)
@@ -498,11 +499,11 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent,
498499

499500
if (!parent->parent) {
500501
/* device under root hub's port */
501-
port1 = usb_hcd_find_raw_port_number(usb_hcd,
502+
raw_port = usb_hcd_find_raw_port_number(usb_hcd,
502503
port1);
503504
}
504505
dev->dev.of_node = usb_of_get_child_node(parent->dev.of_node,
505-
port1);
506+
raw_port);
506507

507508
/* hub driver sets up TT records */
508509
}

drivers/usb/misc/iowarrior.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -787,6 +787,12 @@ 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+
790796
/* set up the endpoint information */
791797
for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) {
792798
endpoint = &iface_desc->endpoint[i].desc;

drivers/usb/storage/uas.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -836,7 +836,7 @@ static struct scsi_host_template uas_host_template = {
836836
.slave_configure = uas_slave_configure,
837837
.eh_abort_handler = uas_eh_abort_handler,
838838
.eh_bus_reset_handler = uas_eh_bus_reset_handler,
839-
.can_queue = 65536, /* Is there a limit on the _host_ ? */
839+
.can_queue = MAX_CMNDS,
840840
.this_id = -1,
841841
.sg_tablesize = SG_NONE,
842842
.skip_settle_delay = 1,

0 commit comments

Comments
 (0)