Skip to content

Commit 8f46c50

Browse files
committed
Merge tag 'usb-3.9-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
Pull USB fixes from Greg Kroah-Hartman: "Here are a number of USB fixes that resolve issues that have been reported against 3.9-rc3." * tag 'usb-3.9-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (37 commits) USB: ti_usb_3410_5052: fix use-after-free in TIOCMIWAIT USB: ssu100: fix use-after-free in TIOCMIWAIT USB: spcp8x5: fix use-after-free in TIOCMIWAIT USB: quatech2: fix use-after-free in TIOCMIWAIT USB: pl2303: fix use-after-free in TIOCMIWAIT USB: oti6858: fix use-after-free in TIOCMIWAIT USB: mos7840: fix use-after-free in TIOCMIWAIT USB: mos7840: fix broken TIOCMIWAIT USB: mct_u232: fix use-after-free in TIOCMIWAIT USB: io_ti: fix use-after-free in TIOCMIWAIT USB: io_edgeport: fix use-after-free in TIOCMIWAIT USB: ftdi_sio: fix use-after-free in TIOCMIWAIT USB: f81232: fix use-after-free in TIOCMIWAIT USB: cypress_m8: fix use-after-free in TIOCMIWAIT USB: ch341: fix use-after-free in TIOCMIWAIT USB: ark3116: fix use-after-free in TIOCMIWAIT USB: serial: add modem-status-change wait queue USB: serial: fix interface refcounting USB: io_ti: fix get_icount for two port adapters USB: garmin_gps: fix memory leak on disconnect ...
2 parents 70dc52f + fc98ab8 commit 8f46c50

36 files changed

Lines changed: 202 additions & 115 deletions

‎drivers/usb/class/cdc-acm.c‎

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,6 @@ static void acm_port_destruct(struct tty_port *port)
593593

594594
dev_dbg(&acm->control->dev, "%s\n", __func__);
595595

596-
tty_unregister_device(acm_tty_driver, acm->minor);
597596
acm_release_minor(acm);
598597
usb_put_intf(acm->control);
599598
kfree(acm->country_codes);
@@ -977,6 +976,8 @@ static int acm_probe(struct usb_interface *intf,
977976
int num_rx_buf;
978977
int i;
979978
int combined_interfaces = 0;
979+
struct device *tty_dev;
980+
int rv = -ENOMEM;
980981

981982
/* normal quirks */
982983
quirks = (unsigned long)id->driver_info;
@@ -1339,11 +1340,24 @@ static int acm_probe(struct usb_interface *intf,
13391340
usb_set_intfdata(data_interface, acm);
13401341

13411342
usb_get_intf(control_interface);
1342-
tty_port_register_device(&acm->port, acm_tty_driver, minor,
1343+
tty_dev = tty_port_register_device(&acm->port, acm_tty_driver, minor,
13431344
&control_interface->dev);
1345+
if (IS_ERR(tty_dev)) {
1346+
rv = PTR_ERR(tty_dev);
1347+
goto alloc_fail8;
1348+
}
13441349

13451350
return 0;
1351+
alloc_fail8:
1352+
if (acm->country_codes) {
1353+
device_remove_file(&acm->control->dev,
1354+
&dev_attr_wCountryCodes);
1355+
device_remove_file(&acm->control->dev,
1356+
&dev_attr_iCountryCodeRelDate);
1357+
}
1358+
device_remove_file(&acm->control->dev, &dev_attr_bmCapabilities);
13461359
alloc_fail7:
1360+
usb_set_intfdata(intf, NULL);
13471361
for (i = 0; i < ACM_NW; i++)
13481362
usb_free_urb(acm->wb[i].urb);
13491363
alloc_fail6:
@@ -1359,7 +1373,7 @@ static int acm_probe(struct usb_interface *intf,
13591373
acm_release_minor(acm);
13601374
kfree(acm);
13611375
alloc_fail:
1362-
return -ENOMEM;
1376+
return rv;
13631377
}
13641378

13651379
static void stop_data_traffic(struct acm *acm)
@@ -1411,6 +1425,8 @@ static void acm_disconnect(struct usb_interface *intf)
14111425

14121426
stop_data_traffic(acm);
14131427

1428+
tty_unregister_device(acm_tty_driver, acm->minor);
1429+
14141430
usb_free_urb(acm->ctrlurb);
14151431
for (i = 0; i < ACM_NW; i++)
14161432
usb_free_urb(acm->wb[i].urb);

‎drivers/usb/core/hcd-pci.c‎

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ int usb_hcd_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
173173
struct hc_driver *driver;
174174
struct usb_hcd *hcd;
175175
int retval;
176+
int hcd_irq = 0;
176177

177178
if (usb_disabled())
178179
return -ENODEV;
@@ -187,15 +188,19 @@ int usb_hcd_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
187188
return -ENODEV;
188189
dev->current_state = PCI_D0;
189190

190-
/* The xHCI driver supports MSI and MSI-X,
191-
* so don't fail if the BIOS doesn't provide a legacy IRQ.
191+
/*
192+
* The xHCI driver has its own irq management
193+
* make sure irq setup is not touched for xhci in generic hcd code
192194
*/
193-
if (!dev->irq && (driver->flags & HCD_MASK) != HCD_USB3) {
194-
dev_err(&dev->dev,
195-
"Found HC with no IRQ. Check BIOS/PCI %s setup!\n",
196-
pci_name(dev));
197-
retval = -ENODEV;
198-
goto disable_pci;
195+
if ((driver->flags & HCD_MASK) != HCD_USB3) {
196+
if (!dev->irq) {
197+
dev_err(&dev->dev,
198+
"Found HC with no IRQ. Check BIOS/PCI %s setup!\n",
199+
pci_name(dev));
200+
retval = -ENODEV;
201+
goto disable_pci;
202+
}
203+
hcd_irq = dev->irq;
199204
}
200205

201206
hcd = usb_create_hcd(driver, &dev->dev, pci_name(dev));
@@ -245,7 +250,7 @@ int usb_hcd_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
245250

246251
pci_set_master(dev);
247252

248-
retval = usb_add_hcd(hcd, dev->irq, IRQF_SHARED);
253+
retval = usb_add_hcd(hcd, hcd_irq, IRQF_SHARED);
249254
if (retval != 0)
250255
goto unmap_registers;
251256
set_hs_companion(dev, hcd);

‎drivers/usb/gadget/f_rndis.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -447,14 +447,13 @@ static void rndis_response_complete(struct usb_ep *ep, struct usb_request *req)
447447
static void rndis_command_complete(struct usb_ep *ep, struct usb_request *req)
448448
{
449449
struct f_rndis *rndis = req->context;
450-
struct usb_composite_dev *cdev = rndis->port.func.config->cdev;
451450
int status;
452451

453452
/* received RNDIS command from USB_CDC_SEND_ENCAPSULATED_COMMAND */
454453
// spin_lock(&dev->lock);
455454
status = rndis_msg_parser(rndis->config, (u8 *) req->buf);
456455
if (status < 0)
457-
ERROR(cdev, "RNDIS command error %d, %d/%d\n",
456+
pr_err("RNDIS command error %d, %d/%d\n",
458457
status, req->actual, req->length);
459458
// spin_unlock(&dev->lock);
460459
}

‎drivers/usb/gadget/g_ffs.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ static int gfs_bind(struct usb_composite_dev *cdev)
357357
goto error;
358358
gfs_dev_desc.iProduct = gfs_strings[USB_GADGET_PRODUCT_IDX].id;
359359

360-
for (i = func_num; --i; ) {
360+
for (i = func_num; i--; ) {
361361
ret = functionfs_bind(ffs_tab[i].ffs_data, cdev);
362362
if (unlikely(ret < 0)) {
363363
while (++i < func_num)
@@ -413,7 +413,7 @@ static int gfs_unbind(struct usb_composite_dev *cdev)
413413
gether_cleanup();
414414
gfs_ether_setup = false;
415415

416-
for (i = func_num; --i; )
416+
for (i = func_num; i--; )
417417
if (ffs_tab[i].ffs_data)
418418
functionfs_unbind(ffs_tab[i].ffs_data);
419419

‎drivers/usb/gadget/net2272.c‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ static const char * const ep_name[] = {
5959
};
6060

6161
#define DMA_ADDR_INVALID (~(dma_addr_t)0)
62-
#ifdef CONFIG_USB_GADGET_NET2272_DMA
62+
#ifdef CONFIG_USB_NET2272_DMA
6363
/*
6464
* use_dma: the NET2272 can use an external DMA controller.
6565
* Note that since there is no generic DMA api, some functions,
@@ -1495,6 +1495,13 @@ stop_activity(struct net2272 *dev, struct usb_gadget_driver *driver)
14951495
for (i = 0; i < 4; ++i)
14961496
net2272_dequeue_all(&dev->ep[i]);
14971497

1498+
/* report disconnect; the driver is already quiesced */
1499+
if (driver) {
1500+
spin_unlock(&dev->lock);
1501+
driver->disconnect(&dev->gadget);
1502+
spin_lock(&dev->lock);
1503+
}
1504+
14981505
net2272_usb_reinit(dev);
14991506
}
15001507

‎drivers/usb/gadget/net2280.c‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1924,7 +1924,6 @@ static int net2280_start(struct usb_gadget *_gadget,
19241924
err_func:
19251925
device_remove_file (&dev->pdev->dev, &dev_attr_function);
19261926
err_unbind:
1927-
driver->unbind (&dev->gadget);
19281927
dev->gadget.dev.driver = NULL;
19291928
dev->driver = NULL;
19301929
return retval;
@@ -1946,6 +1945,13 @@ stop_activity (struct net2280 *dev, struct usb_gadget_driver *driver)
19461945
for (i = 0; i < 7; i++)
19471946
nuke (&dev->ep [i]);
19481947

1948+
/* report disconnect; the driver is already quiesced */
1949+
if (driver) {
1950+
spin_unlock(&dev->lock);
1951+
driver->disconnect(&dev->gadget);
1952+
spin_lock(&dev->lock);
1953+
}
1954+
19491955
usb_reinit (dev);
19501956
}
19511957

‎drivers/usb/gadget/u_serial.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ static struct portmaster {
136136
pr_debug(fmt, ##arg)
137137
#endif /* pr_vdebug */
138138
#else
139-
#ifndef pr_vdebig
139+
#ifndef pr_vdebug
140140
#define pr_vdebug(fmt, arg...) \
141141
({ if (0) pr_debug(fmt, ##arg); })
142142
#endif /* pr_vdebug */

‎drivers/usb/gadget/udc-core.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ static void usb_gadget_remove_driver(struct usb_udc *udc)
216216
usb_gadget_disconnect(udc->gadget);
217217
udc->driver->disconnect(udc->gadget);
218218
udc->driver->unbind(udc->gadget);
219-
usb_gadget_udc_stop(udc->gadget, udc->driver);
219+
usb_gadget_udc_stop(udc->gadget, NULL);
220220

221221
udc->driver = NULL;
222222
udc->dev.driver = NULL;

‎drivers/usb/host/ehci-hcd.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ static void ehci_quiesce (struct ehci_hcd *ehci)
302302

303303
static void end_unlink_async(struct ehci_hcd *ehci);
304304
static void unlink_empty_async(struct ehci_hcd *ehci);
305+
static void unlink_empty_async_suspended(struct ehci_hcd *ehci);
305306
static void ehci_work(struct ehci_hcd *ehci);
306307
static void start_unlink_intr(struct ehci_hcd *ehci, struct ehci_qh *qh);
307308
static void end_unlink_intr(struct ehci_hcd *ehci, struct ehci_qh *qh);

‎drivers/usb/host/ehci-hub.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ static int ehci_bus_suspend (struct usb_hcd *hcd)
328328
ehci->rh_state = EHCI_RH_SUSPENDED;
329329

330330
end_unlink_async(ehci);
331-
unlink_empty_async(ehci);
331+
unlink_empty_async_suspended(ehci);
332332
ehci_handle_intr_unlinks(ehci);
333333
end_free_itds(ehci);
334334

0 commit comments

Comments
 (0)