Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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
...

+202 -115
+19 -3
drivers/usb/class/cdc-acm.c
··· 593 593 594 594 dev_dbg(&acm->control->dev, "%s\n", __func__); 595 595 596 - tty_unregister_device(acm_tty_driver, acm->minor); 597 596 acm_release_minor(acm); 598 597 usb_put_intf(acm->control); 599 598 kfree(acm->country_codes); ··· 976 977 int num_rx_buf; 977 978 int i; 978 979 int combined_interfaces = 0; 980 + struct device *tty_dev; 981 + int rv = -ENOMEM; 979 982 980 983 /* normal quirks */ 981 984 quirks = (unsigned long)id->driver_info; ··· 1340 1339 usb_set_intfdata(data_interface, acm); 1341 1340 1342 1341 usb_get_intf(control_interface); 1343 - tty_port_register_device(&acm->port, acm_tty_driver, minor, 1342 + tty_dev = tty_port_register_device(&acm->port, acm_tty_driver, minor, 1344 1343 &control_interface->dev); 1344 + if (IS_ERR(tty_dev)) { 1345 + rv = PTR_ERR(tty_dev); 1346 + goto alloc_fail8; 1347 + } 1345 1348 1346 1349 return 0; 1350 + alloc_fail8: 1351 + if (acm->country_codes) { 1352 + device_remove_file(&acm->control->dev, 1353 + &dev_attr_wCountryCodes); 1354 + device_remove_file(&acm->control->dev, 1355 + &dev_attr_iCountryCodeRelDate); 1356 + } 1357 + device_remove_file(&acm->control->dev, &dev_attr_bmCapabilities); 1347 1358 alloc_fail7: 1359 + usb_set_intfdata(intf, NULL); 1348 1360 for (i = 0; i < ACM_NW; i++) 1349 1361 usb_free_urb(acm->wb[i].urb); 1350 1362 alloc_fail6: ··· 1373 1359 acm_release_minor(acm); 1374 1360 kfree(acm); 1375 1361 alloc_fail: 1376 - return -ENOMEM; 1362 + return rv; 1377 1363 } 1378 1364 1379 1365 static void stop_data_traffic(struct acm *acm) ··· 1424 1410 } 1425 1411 1426 1412 stop_data_traffic(acm); 1413 + 1414 + tty_unregister_device(acm_tty_driver, acm->minor); 1427 1415 1428 1416 usb_free_urb(acm->ctrlurb); 1429 1417 for (i = 0; i < ACM_NW; i++)
+14 -9
drivers/usb/core/hcd-pci.c
··· 173 173 struct hc_driver *driver; 174 174 struct usb_hcd *hcd; 175 175 int retval; 176 + int hcd_irq = 0; 176 177 177 178 if (usb_disabled()) 178 179 return -ENODEV; ··· 188 187 return -ENODEV; 189 188 dev->current_state = PCI_D0; 190 189 191 - /* The xHCI driver supports MSI and MSI-X, 192 - * so don't fail if the BIOS doesn't provide a legacy IRQ. 190 + /* 191 + * The xHCI driver has its own irq management 192 + * make sure irq setup is not touched for xhci in generic hcd code 193 193 */ 194 - if (!dev->irq && (driver->flags & HCD_MASK) != HCD_USB3) { 195 - dev_err(&dev->dev, 196 - "Found HC with no IRQ. Check BIOS/PCI %s setup!\n", 197 - pci_name(dev)); 198 - retval = -ENODEV; 199 - goto disable_pci; 194 + if ((driver->flags & HCD_MASK) != HCD_USB3) { 195 + if (!dev->irq) { 196 + dev_err(&dev->dev, 197 + "Found HC with no IRQ. Check BIOS/PCI %s setup!\n", 198 + pci_name(dev)); 199 + retval = -ENODEV; 200 + goto disable_pci; 201 + } 202 + hcd_irq = dev->irq; 200 203 } 201 204 202 205 hcd = usb_create_hcd(driver, &dev->dev, pci_name(dev)); ··· 250 245 251 246 pci_set_master(dev); 252 247 253 - retval = usb_add_hcd(hcd, dev->irq, IRQF_SHARED); 248 + retval = usb_add_hcd(hcd, hcd_irq, IRQF_SHARED); 254 249 if (retval != 0) 255 250 goto unmap_registers; 256 251 set_hs_companion(dev, hcd);
+1 -2
drivers/usb/gadget/f_rndis.c
··· 447 447 static void rndis_command_complete(struct usb_ep *ep, struct usb_request *req) 448 448 { 449 449 struct f_rndis *rndis = req->context; 450 - struct usb_composite_dev *cdev = rndis->port.func.config->cdev; 451 450 int status; 452 451 453 452 /* received RNDIS command from USB_CDC_SEND_ENCAPSULATED_COMMAND */ 454 453 // spin_lock(&dev->lock); 455 454 status = rndis_msg_parser(rndis->config, (u8 *) req->buf); 456 455 if (status < 0) 457 - ERROR(cdev, "RNDIS command error %d, %d/%d\n", 456 + pr_err("RNDIS command error %d, %d/%d\n", 458 457 status, req->actual, req->length); 459 458 // spin_unlock(&dev->lock); 460 459 }
+2 -2
drivers/usb/gadget/g_ffs.c
··· 357 357 goto error; 358 358 gfs_dev_desc.iProduct = gfs_strings[USB_GADGET_PRODUCT_IDX].id; 359 359 360 - for (i = func_num; --i; ) { 360 + for (i = func_num; i--; ) { 361 361 ret = functionfs_bind(ffs_tab[i].ffs_data, cdev); 362 362 if (unlikely(ret < 0)) { 363 363 while (++i < func_num) ··· 413 413 gether_cleanup(); 414 414 gfs_ether_setup = false; 415 415 416 - for (i = func_num; --i; ) 416 + for (i = func_num; i--; ) 417 417 if (ffs_tab[i].ffs_data) 418 418 functionfs_unbind(ffs_tab[i].ffs_data); 419 419
+8 -1
drivers/usb/gadget/net2272.c
··· 59 59 }; 60 60 61 61 #define DMA_ADDR_INVALID (~(dma_addr_t)0) 62 - #ifdef CONFIG_USB_GADGET_NET2272_DMA 62 + #ifdef CONFIG_USB_NET2272_DMA 63 63 /* 64 64 * use_dma: the NET2272 can use an external DMA controller. 65 65 * Note that since there is no generic DMA api, some functions, ··· 1494 1494 net2272_usb_reset(dev); 1495 1495 for (i = 0; i < 4; ++i) 1496 1496 net2272_dequeue_all(&dev->ep[i]); 1497 + 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 + } 1497 1504 1498 1505 net2272_usb_reinit(dev); 1499 1506 }
+7 -1
drivers/usb/gadget/net2280.c
··· 1924 1924 err_func: 1925 1925 device_remove_file (&dev->pdev->dev, &dev_attr_function); 1926 1926 err_unbind: 1927 - driver->unbind (&dev->gadget); 1928 1927 dev->gadget.dev.driver = NULL; 1929 1928 dev->driver = NULL; 1930 1929 return retval; ··· 1944 1945 usb_reset (dev); 1945 1946 for (i = 0; i < 7; i++) 1946 1947 nuke (&dev->ep [i]); 1948 + 1949 + /* report disconnect; the driver is already quiesced */ 1950 + if (driver) { 1951 + spin_unlock(&dev->lock); 1952 + driver->disconnect(&dev->gadget); 1953 + spin_lock(&dev->lock); 1954 + } 1947 1955 1948 1956 usb_reinit (dev); 1949 1957 }
+1 -1
drivers/usb/gadget/u_serial.c
··· 136 136 pr_debug(fmt, ##arg) 137 137 #endif /* pr_vdebug */ 138 138 #else 139 - #ifndef pr_vdebig 139 + #ifndef pr_vdebug 140 140 #define pr_vdebug(fmt, arg...) \ 141 141 ({ if (0) pr_debug(fmt, ##arg); }) 142 142 #endif /* pr_vdebug */
+1 -1
drivers/usb/gadget/udc-core.c
··· 216 216 usb_gadget_disconnect(udc->gadget); 217 217 udc->driver->disconnect(udc->gadget); 218 218 udc->driver->unbind(udc->gadget); 219 - usb_gadget_udc_stop(udc->gadget, udc->driver); 219 + usb_gadget_udc_stop(udc->gadget, NULL); 220 220 221 221 udc->driver = NULL; 222 222 udc->dev.driver = NULL;
+1
drivers/usb/host/ehci-hcd.c
··· 302 302 303 303 static void end_unlink_async(struct ehci_hcd *ehci); 304 304 static void unlink_empty_async(struct ehci_hcd *ehci); 305 + static void unlink_empty_async_suspended(struct ehci_hcd *ehci); 305 306 static void ehci_work(struct ehci_hcd *ehci); 306 307 static void start_unlink_intr(struct ehci_hcd *ehci, struct ehci_qh *qh); 307 308 static void end_unlink_intr(struct ehci_hcd *ehci, struct ehci_qh *qh);
+1 -1
drivers/usb/host/ehci-hub.c
··· 328 328 ehci->rh_state = EHCI_RH_SUSPENDED; 329 329 330 330 end_unlink_async(ehci); 331 - unlink_empty_async(ehci); 331 + unlink_empty_async_suspended(ehci); 332 332 ehci_handle_intr_unlinks(ehci); 333 333 end_free_itds(ehci); 334 334
+13
drivers/usb/host/ehci-q.c
··· 1316 1316 } 1317 1317 } 1318 1318 1319 + /* The root hub is suspended; unlink all the async QHs */ 1320 + static void unlink_empty_async_suspended(struct ehci_hcd *ehci) 1321 + { 1322 + struct ehci_qh *qh; 1323 + 1324 + while (ehci->async->qh_next.qh) { 1325 + qh = ehci->async->qh_next.qh; 1326 + WARN_ON(!list_empty(&qh->qtd_list)); 1327 + single_unlink_async(ehci, qh); 1328 + } 1329 + start_iaa_cycle(ehci, false); 1330 + } 1331 + 1319 1332 /* makes sure the async qh will become idle */ 1320 1333 /* caller must own ehci->lock */ 1321 1334
+1 -1
drivers/usb/host/ehci-timer.c
··· 304 304 * (a) SMP races against real IAA firing and retriggering, and 305 305 * (b) clean HC shutdown, when IAA watchdog was pending. 306 306 */ 307 - if (ehci->async_iaa) { 307 + if (1) { 308 308 u32 cmd, status; 309 309 310 310 /* If we get here, IAA is *REALLY* late. It's barely
+2 -1
drivers/usb/host/xhci.c
··· 350 350 * generate interrupts. Don't even try to enable MSI. 351 351 */ 352 352 if (xhci->quirks & XHCI_BROKEN_MSI) 353 - return 0; 353 + goto legacy_irq; 354 354 355 355 /* unregister the legacy interrupt */ 356 356 if (hcd->irq) ··· 371 371 return -EINVAL; 372 372 } 373 373 374 + legacy_irq: 374 375 /* fall back to legacy interrupt*/ 375 376 ret = request_irq(pdev->irq, &usb_hcd_irq, IRQF_SHARED, 376 377 hcd->irq_descr, hcd);
+2 -2
drivers/usb/host/xhci.h
··· 206 206 /* bits 12:31 are reserved (and should be preserved on writes). */ 207 207 208 208 /* IMAN - Interrupt Management Register */ 209 - #define IMAN_IP (1 << 1) 210 - #define IMAN_IE (1 << 0) 209 + #define IMAN_IE (1 << 1) 210 + #define IMAN_IP (1 << 0) 211 211 212 212 /* USBSTS - USB status - status bitmasks */ 213 213 /* HC not running - set to 1 when run/stop bit is cleared. */
+1 -1
drivers/usb/musb/da8xx.c
··· 327 327 u8 devctl = musb_readb(mregs, MUSB_DEVCTL); 328 328 int err; 329 329 330 - err = musb->int_usb & USB_INTR_VBUSERROR; 330 + err = musb->int_usb & MUSB_INTR_VBUSERROR; 331 331 if (err) { 332 332 /* 333 333 * The Mentor core doesn't debounce VBUS as needed
+7 -2
drivers/usb/musb/musb_gadget.c
··· 141 141 static inline void unmap_dma_buffer(struct musb_request *request, 142 142 struct musb *musb) 143 143 { 144 - if (!is_buffer_mapped(request)) 144 + struct musb_ep *musb_ep = request->ep; 145 + 146 + if (!is_buffer_mapped(request) || !musb_ep->dma) 145 147 return; 146 148 147 149 if (request->request.dma == DMA_ADDR_INVALID) { ··· 197 195 198 196 ep->busy = 1; 199 197 spin_unlock(&musb->lock); 200 - unmap_dma_buffer(req, musb); 198 + 199 + if (!dma_mapping_error(&musb->g.dev, request->dma)) 200 + unmap_dma_buffer(req, musb); 201 + 201 202 if (request->status == 0) 202 203 dev_dbg(musb->controller, "%s done request %p, %d/%d\n", 203 204 ep->end_point.name, request,
+6 -4
drivers/usb/serial/ark3116.c
··· 62 62 } 63 63 64 64 struct ark3116_private { 65 - wait_queue_head_t delta_msr_wait; 66 65 struct async_icount icount; 67 66 int irda; /* 1 for irda device */ 68 67 ··· 145 146 if (!priv) 146 147 return -ENOMEM; 147 148 148 - init_waitqueue_head(&priv->delta_msr_wait); 149 149 mutex_init(&priv->hw_lock); 150 150 spin_lock_init(&priv->status_lock); 151 151 ··· 454 456 case TIOCMIWAIT: 455 457 for (;;) { 456 458 struct async_icount prev = priv->icount; 457 - interruptible_sleep_on(&priv->delta_msr_wait); 459 + interruptible_sleep_on(&port->delta_msr_wait); 458 460 /* see if a signal did it */ 459 461 if (signal_pending(current)) 460 462 return -ERESTARTSYS; 463 + 464 + if (port->serial->disconnected) 465 + return -EIO; 466 + 461 467 if ((prev.rng == priv->icount.rng) && 462 468 (prev.dsr == priv->icount.dsr) && 463 469 (prev.dcd == priv->icount.dcd) && ··· 582 580 priv->icount.dcd++; 583 581 if (msr & UART_MSR_TERI) 584 582 priv->icount.rng++; 585 - wake_up_interruptible(&priv->delta_msr_wait); 583 + wake_up_interruptible(&port->delta_msr_wait); 586 584 } 587 585 } 588 586
+6 -5
drivers/usb/serial/ch341.c
··· 80 80 81 81 struct ch341_private { 82 82 spinlock_t lock; /* access lock */ 83 - wait_queue_head_t delta_msr_wait; /* wait queue for modem status */ 84 83 unsigned baud_rate; /* set baud rate */ 85 84 u8 line_control; /* set line control value RTS/DTR */ 86 85 u8 line_status; /* active status of modem control inputs */ ··· 251 252 return -ENOMEM; 252 253 253 254 spin_lock_init(&priv->lock); 254 - init_waitqueue_head(&priv->delta_msr_wait); 255 255 priv->baud_rate = DEFAULT_BAUD_RATE; 256 256 priv->line_control = CH341_BIT_RTS | CH341_BIT_DTR; 257 257 ··· 296 298 priv->line_control &= ~(CH341_BIT_RTS | CH341_BIT_DTR); 297 299 spin_unlock_irqrestore(&priv->lock, flags); 298 300 ch341_set_handshake(port->serial->dev, priv->line_control); 299 - wake_up_interruptible(&priv->delta_msr_wait); 301 + wake_up_interruptible(&port->delta_msr_wait); 300 302 } 301 303 302 304 static void ch341_close(struct usb_serial_port *port) ··· 489 491 tty_kref_put(tty); 490 492 } 491 493 492 - wake_up_interruptible(&priv->delta_msr_wait); 494 + wake_up_interruptible(&port->delta_msr_wait); 493 495 } 494 496 495 497 exit: ··· 515 517 spin_unlock_irqrestore(&priv->lock, flags); 516 518 517 519 while (!multi_change) { 518 - interruptible_sleep_on(&priv->delta_msr_wait); 520 + interruptible_sleep_on(&port->delta_msr_wait); 519 521 /* see if a signal did it */ 520 522 if (signal_pending(current)) 521 523 return -ERESTARTSYS; 524 + 525 + if (port->serial->disconnected) 526 + return -EIO; 522 527 523 528 spin_lock_irqsave(&priv->lock, flags); 524 529 status = priv->line_status;
+8 -6
drivers/usb/serial/cypress_m8.c
··· 111 111 int baud_rate; /* stores current baud rate in 112 112 integer form */ 113 113 int isthrottled; /* if throttled, discard reads */ 114 - wait_queue_head_t delta_msr_wait; /* used for TIOCMIWAIT */ 115 114 char prev_status, diff_status; /* used for TIOCMIWAIT */ 116 115 /* we pass a pointer to this as the argument sent to 117 116 cypress_set_termios old_termios */ ··· 448 449 kfree(priv); 449 450 return -ENOMEM; 450 451 } 451 - init_waitqueue_head(&priv->delta_msr_wait); 452 452 453 453 usb_reset_configuration(serial->dev); 454 454 ··· 866 868 switch (cmd) { 867 869 /* This code comes from drivers/char/serial.c and ftdi_sio.c */ 868 870 case TIOCMIWAIT: 869 - while (priv != NULL) { 870 - interruptible_sleep_on(&priv->delta_msr_wait); 871 + for (;;) { 872 + interruptible_sleep_on(&port->delta_msr_wait); 871 873 /* see if a signal did it */ 872 874 if (signal_pending(current)) 873 875 return -ERESTARTSYS; 874 - else { 876 + 877 + if (port->serial->disconnected) 878 + return -EIO; 879 + 880 + { 875 881 char diff = priv->diff_status; 876 882 if (diff == 0) 877 883 return -EIO; /* no change => error */ ··· 1189 1187 if (priv->current_status != priv->prev_status) { 1190 1188 priv->diff_status |= priv->current_status ^ 1191 1189 priv->prev_status; 1192 - wake_up_interruptible(&priv->delta_msr_wait); 1190 + wake_up_interruptible(&port->delta_msr_wait); 1193 1191 priv->prev_status = priv->current_status; 1194 1192 } 1195 1193 spin_unlock_irqrestore(&priv->lock, flags);
+5 -4
drivers/usb/serial/f81232.c
··· 47 47 48 48 struct f81232_private { 49 49 spinlock_t lock; 50 - wait_queue_head_t delta_msr_wait; 51 50 u8 line_control; 52 51 u8 line_status; 53 52 }; ··· 110 111 line_status = priv->line_status; 111 112 priv->line_status &= ~UART_STATE_TRANSIENT_MASK; 112 113 spin_unlock_irqrestore(&priv->lock, flags); 113 - wake_up_interruptible(&priv->delta_msr_wait); 114 + wake_up_interruptible(&port->delta_msr_wait); 114 115 115 116 if (!urb->actual_length) 116 117 return; ··· 255 256 spin_unlock_irqrestore(&priv->lock, flags); 256 257 257 258 while (1) { 258 - interruptible_sleep_on(&priv->delta_msr_wait); 259 + interruptible_sleep_on(&port->delta_msr_wait); 259 260 /* see if a signal did it */ 260 261 if (signal_pending(current)) 261 262 return -ERESTARTSYS; 263 + 264 + if (port->serial->disconnected) 265 + return -EIO; 262 266 263 267 spin_lock_irqsave(&priv->lock, flags); 264 268 status = priv->line_status; ··· 324 322 return -ENOMEM; 325 323 326 324 spin_lock_init(&priv->lock); 327 - init_waitqueue_head(&priv->delta_msr_wait); 328 325 329 326 usb_set_serial_port_data(port, priv); 330 327
+8 -11
drivers/usb/serial/ftdi_sio.c
··· 69 69 int flags; /* some ASYNC_xxxx flags are supported */ 70 70 unsigned long last_dtr_rts; /* saved modem control outputs */ 71 71 struct async_icount icount; 72 - wait_queue_head_t delta_msr_wait; /* Used for TIOCMIWAIT */ 73 72 char prev_status; /* Used for TIOCMIWAIT */ 74 - bool dev_gone; /* Used to abort TIOCMIWAIT */ 75 73 char transmit_empty; /* If transmitter is empty or not */ 76 74 __u16 interface; /* FT2232C, FT2232H or FT4232H port interface 77 75 (0 for FT232/245) */ ··· 1689 1691 1690 1692 kref_init(&priv->kref); 1691 1693 mutex_init(&priv->cfg_lock); 1692 - init_waitqueue_head(&priv->delta_msr_wait); 1693 1694 1694 1695 priv->flags = ASYNC_LOW_LATENCY; 1695 - priv->dev_gone = false; 1696 1696 1697 1697 if (quirk && quirk->port_probe) 1698 1698 quirk->port_probe(priv); ··· 1836 1840 { 1837 1841 struct ftdi_private *priv = usb_get_serial_port_data(port); 1838 1842 1839 - priv->dev_gone = true; 1840 - wake_up_interruptible_all(&priv->delta_msr_wait); 1843 + wake_up_interruptible(&port->delta_msr_wait); 1841 1844 1842 1845 remove_sysfs_attrs(port); 1843 1846 ··· 1984 1989 if (diff_status & FTDI_RS0_RLSD) 1985 1990 priv->icount.dcd++; 1986 1991 1987 - wake_up_interruptible_all(&priv->delta_msr_wait); 1992 + wake_up_interruptible(&port->delta_msr_wait); 1988 1993 priv->prev_status = status; 1989 1994 } 1990 1995 ··· 2435 2440 */ 2436 2441 case TIOCMIWAIT: 2437 2442 cprev = priv->icount; 2438 - while (!priv->dev_gone) { 2439 - interruptible_sleep_on(&priv->delta_msr_wait); 2443 + for (;;) { 2444 + interruptible_sleep_on(&port->delta_msr_wait); 2440 2445 /* see if a signal did it */ 2441 2446 if (signal_pending(current)) 2442 2447 return -ERESTARTSYS; 2448 + 2449 + if (port->serial->disconnected) 2450 + return -EIO; 2451 + 2443 2452 cnow = priv->icount; 2444 2453 if (((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) || 2445 2454 ((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) || ··· 2453 2454 } 2454 2455 cprev = cnow; 2455 2456 } 2456 - return -EIO; 2457 - break; 2458 2457 case TIOCSERGETLSR: 2459 2458 return get_lsr_info(port, (struct serial_struct __user *)arg); 2460 2459 break;
+1 -6
drivers/usb/serial/garmin_gps.c
··· 956 956 if (!serial) 957 957 return; 958 958 959 - mutex_lock(&port->serial->disc_mutex); 960 - 961 - if (!port->serial->disconnected) 962 - garmin_clear(garmin_data_p); 959 + garmin_clear(garmin_data_p); 963 960 964 961 /* shutdown our urbs */ 965 962 usb_kill_urb(port->read_urb); ··· 965 968 /* keep reset state so we know that we must start a new session */ 966 969 if (garmin_data_p->state != STATE_RESET) 967 970 garmin_data_p->state = STATE_DISCONNECTED; 968 - 969 - mutex_unlock(&port->serial->disc_mutex); 970 971 } 971 972 972 973
+7 -5
drivers/usb/serial/io_edgeport.c
··· 110 110 wait_queue_head_t wait_chase; /* for handling sleeping while waiting for chase to finish */ 111 111 wait_queue_head_t wait_open; /* for handling sleeping while waiting for open to finish */ 112 112 wait_queue_head_t wait_command; /* for handling sleeping while waiting for command to finish */ 113 - wait_queue_head_t delta_msr_wait; /* for handling sleeping while waiting for msr change to happen */ 114 113 115 114 struct async_icount icount; 116 115 struct usb_serial_port *port; /* loop back to the owner of this object */ ··· 883 884 /* initialize our wait queues */ 884 885 init_waitqueue_head(&edge_port->wait_open); 885 886 init_waitqueue_head(&edge_port->wait_chase); 886 - init_waitqueue_head(&edge_port->delta_msr_wait); 887 887 init_waitqueue_head(&edge_port->wait_command); 888 888 889 889 /* initialize our icount structure */ ··· 1667 1669 dev_dbg(&port->dev, "%s (%d) TIOCMIWAIT\n", __func__, port->number); 1668 1670 cprev = edge_port->icount; 1669 1671 while (1) { 1670 - prepare_to_wait(&edge_port->delta_msr_wait, 1672 + prepare_to_wait(&port->delta_msr_wait, 1671 1673 &wait, TASK_INTERRUPTIBLE); 1672 1674 schedule(); 1673 - finish_wait(&edge_port->delta_msr_wait, &wait); 1675 + finish_wait(&port->delta_msr_wait, &wait); 1674 1676 /* see if a signal did it */ 1675 1677 if (signal_pending(current)) 1676 1678 return -ERESTARTSYS; 1679 + 1680 + if (port->serial->disconnected) 1681 + return -EIO; 1682 + 1677 1683 cnow = edge_port->icount; 1678 1684 if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr && 1679 1685 cnow.dcd == cprev.dcd && cnow.cts == cprev.cts) ··· 2053 2051 icount->dcd++; 2054 2052 if (newMsr & EDGEPORT_MSR_DELTA_RI) 2055 2053 icount->rng++; 2056 - wake_up_interruptible(&edge_port->delta_msr_wait); 2054 + wake_up_interruptible(&edge_port->port->delta_msr_wait); 2057 2055 } 2058 2056 2059 2057 /* Save the new modem status */
+7 -6
drivers/usb/serial/io_ti.c
··· 87 87 int close_pending; 88 88 int lsr_event; 89 89 struct async_icount icount; 90 - wait_queue_head_t delta_msr_wait; /* for handling sleeping while 91 - waiting for msr change to 92 - happen */ 93 90 struct edgeport_serial *edge_serial; 94 91 struct usb_serial_port *port; 95 92 __u8 bUartMode; /* Port type, 0: RS232, etc. */ ··· 1456 1459 icount->dcd++; 1457 1460 if (msr & EDGEPORT_MSR_DELTA_RI) 1458 1461 icount->rng++; 1459 - wake_up_interruptible(&edge_port->delta_msr_wait); 1462 + wake_up_interruptible(&edge_port->port->delta_msr_wait); 1460 1463 } 1461 1464 1462 1465 /* Save the new modem status */ ··· 1751 1754 dev = port->serial->dev; 1752 1755 1753 1756 memset(&(edge_port->icount), 0x00, sizeof(edge_port->icount)); 1754 - init_waitqueue_head(&edge_port->delta_msr_wait); 1755 1757 1756 1758 /* turn off loopback */ 1757 1759 status = ti_do_config(edge_port, UMPC_SET_CLR_LOOPBACK, 0); ··· 2430 2434 dev_dbg(&port->dev, "%s - TIOCMIWAIT\n", __func__); 2431 2435 cprev = edge_port->icount; 2432 2436 while (1) { 2433 - interruptible_sleep_on(&edge_port->delta_msr_wait); 2437 + interruptible_sleep_on(&port->delta_msr_wait); 2434 2438 /* see if a signal did it */ 2435 2439 if (signal_pending(current)) 2436 2440 return -ERESTARTSYS; 2441 + 2442 + if (port->serial->disconnected) 2443 + return -EIO; 2444 + 2437 2445 cnow = edge_port->icount; 2438 2446 if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr && 2439 2447 cnow.dcd == cprev.dcd && cnow.cts == cprev.cts) ··· 2649 2649 .set_termios = edge_set_termios, 2650 2650 .tiocmget = edge_tiocmget, 2651 2651 .tiocmset = edge_tiocmset, 2652 + .get_icount = edge_get_icount, 2652 2653 .write = edge_write, 2653 2654 .write_room = edge_write_room, 2654 2655 .chars_in_buffer = edge_chars_in_buffer,
+7 -6
drivers/usb/serial/mct_u232.c
··· 114 114 unsigned char last_msr; /* Modem Status Register */ 115 115 unsigned int rx_flags; /* Throttling flags */ 116 116 struct async_icount icount; 117 - wait_queue_head_t msr_wait; /* for handling sleeping while waiting 118 - for msr change to happen */ 119 117 }; 120 118 121 119 #define THROTTLED 0x01 ··· 407 409 return -ENOMEM; 408 410 409 411 spin_lock_init(&priv->lock); 410 - init_waitqueue_head(&priv->msr_wait); 411 412 412 413 usb_set_serial_port_data(port, priv); 413 414 ··· 598 601 tty_kref_put(tty); 599 602 } 600 603 #endif 601 - wake_up_interruptible(&priv->msr_wait); 604 + wake_up_interruptible(&port->delta_msr_wait); 602 605 spin_unlock_irqrestore(&priv->lock, flags); 603 606 exit: 604 607 retval = usb_submit_urb(urb, GFP_ATOMIC); ··· 807 810 cprev = mct_u232_port->icount; 808 811 spin_unlock_irqrestore(&mct_u232_port->lock, flags); 809 812 for ( ; ; ) { 810 - prepare_to_wait(&mct_u232_port->msr_wait, 813 + prepare_to_wait(&port->delta_msr_wait, 811 814 &wait, TASK_INTERRUPTIBLE); 812 815 schedule(); 813 - finish_wait(&mct_u232_port->msr_wait, &wait); 816 + finish_wait(&port->delta_msr_wait, &wait); 814 817 /* see if a signal did it */ 815 818 if (signal_pending(current)) 816 819 return -ERESTARTSYS; 820 + 821 + if (port->serial->disconnected) 822 + return -EIO; 823 + 817 824 spin_lock_irqsave(&mct_u232_port->lock, flags); 818 825 cnow = mct_u232_port->icount; 819 826 spin_unlock_irqrestore(&mct_u232_port->lock, flags);
+10 -6
drivers/usb/serial/mos7840.c
··· 219 219 char open; 220 220 char open_ports; 221 221 wait_queue_head_t wait_chase; /* for handling sleeping while waiting for chase to finish */ 222 - wait_queue_head_t delta_msr_wait; /* for handling sleeping while waiting for msr change to happen */ 223 222 int delta_msr_cond; 224 223 struct async_icount icount; 225 224 struct usb_serial_port *port; /* loop back to the owner of this object */ ··· 422 423 icount->rng++; 423 424 smp_wmb(); 424 425 } 426 + 427 + mos7840_port->delta_msr_cond = 1; 428 + wake_up_interruptible(&port->port->delta_msr_wait); 425 429 } 426 430 } 427 431 ··· 1129 1127 1130 1128 /* initialize our wait queues */ 1131 1129 init_waitqueue_head(&mos7840_port->wait_chase); 1132 - init_waitqueue_head(&mos7840_port->delta_msr_wait); 1133 1130 1134 1131 /* initialize our icount structure */ 1135 1132 memset(&(mos7840_port->icount), 0x00, sizeof(mos7840_port->icount)); ··· 2018 2017 mos7840_port->read_urb_busy = false; 2019 2018 } 2020 2019 } 2021 - wake_up(&mos7840_port->delta_msr_wait); 2022 - mos7840_port->delta_msr_cond = 1; 2023 2020 dev_dbg(&port->dev, "%s - mos7840_port->shadowLCR is End %x\n", __func__, 2024 2021 mos7840_port->shadowLCR); 2025 2022 } ··· 2218 2219 while (1) { 2219 2220 /* interruptible_sleep_on(&mos7840_port->delta_msr_wait); */ 2220 2221 mos7840_port->delta_msr_cond = 0; 2221 - wait_event_interruptible(mos7840_port->delta_msr_wait, 2222 - (mos7840_port-> 2222 + wait_event_interruptible(port->delta_msr_wait, 2223 + (port->serial->disconnected || 2224 + mos7840_port-> 2223 2225 delta_msr_cond == 1)); 2224 2226 2225 2227 /* see if a signal did it */ 2226 2228 if (signal_pending(current)) 2227 2229 return -ERESTARTSYS; 2230 + 2231 + if (port->serial->disconnected) 2232 + return -EIO; 2233 + 2228 2234 cnow = mos7840_port->icount; 2229 2235 smp_rmb(); 2230 2236 if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr &&
+6 -4
drivers/usb/serial/oti6858.c
··· 188 188 u8 setup_done; 189 189 struct delayed_work delayed_setup_work; 190 190 191 - wait_queue_head_t intr_wait; 192 191 struct usb_serial_port *port; /* USB port with which associated */ 193 192 }; 194 193 ··· 338 339 return -ENOMEM; 339 340 340 341 spin_lock_init(&priv->lock); 341 - init_waitqueue_head(&priv->intr_wait); 342 342 priv->port = port; 343 343 INIT_DELAYED_WORK(&priv->delayed_setup_work, setup_line); 344 344 INIT_DELAYED_WORK(&priv->delayed_write_work, send_data); ··· 662 664 spin_unlock_irqrestore(&priv->lock, flags); 663 665 664 666 while (1) { 665 - wait_event_interruptible(priv->intr_wait, 667 + wait_event_interruptible(port->delta_msr_wait, 668 + port->serial->disconnected || 666 669 priv->status.pin_state != prev); 667 670 if (signal_pending(current)) 668 671 return -ERESTARTSYS; 672 + 673 + if (port->serial->disconnected) 674 + return -EIO; 669 675 670 676 spin_lock_irqsave(&priv->lock, flags); 671 677 status = priv->status.pin_state & PIN_MASK; ··· 765 763 766 764 if (!priv->transient) { 767 765 if (xs->pin_state != priv->status.pin_state) 768 - wake_up_interruptible(&priv->intr_wait); 766 + wake_up_interruptible(&port->delta_msr_wait); 769 767 memcpy(&priv->status, xs, OTI6858_CTRL_PKT_SIZE); 770 768 } 771 769
+6 -5
drivers/usb/serial/pl2303.c
··· 139 139 140 140 struct pl2303_private { 141 141 spinlock_t lock; 142 - wait_queue_head_t delta_msr_wait; 143 142 u8 line_control; 144 143 u8 line_status; 145 144 }; ··· 232 233 return -ENOMEM; 233 234 234 235 spin_lock_init(&priv->lock); 235 - init_waitqueue_head(&priv->delta_msr_wait); 236 236 237 237 usb_set_serial_port_data(port, priv); 238 238 ··· 605 607 spin_unlock_irqrestore(&priv->lock, flags); 606 608 607 609 while (1) { 608 - interruptible_sleep_on(&priv->delta_msr_wait); 610 + interruptible_sleep_on(&port->delta_msr_wait); 609 611 /* see if a signal did it */ 610 612 if (signal_pending(current)) 611 613 return -ERESTARTSYS; 614 + 615 + if (port->serial->disconnected) 616 + return -EIO; 612 617 613 618 spin_lock_irqsave(&priv->lock, flags); 614 619 status = priv->line_status; ··· 720 719 spin_unlock_irqrestore(&priv->lock, flags); 721 720 if (priv->line_status & UART_BREAK_ERROR) 722 721 usb_serial_handle_break(port); 723 - wake_up_interruptible(&priv->delta_msr_wait); 722 + wake_up_interruptible(&port->delta_msr_wait); 724 723 725 724 tty = tty_port_tty_get(&port->port); 726 725 if (!tty) ··· 784 783 line_status = priv->line_status; 785 784 priv->line_status &= ~UART_STATE_TRANSIENT_MASK; 786 785 spin_unlock_irqrestore(&priv->lock, flags); 787 - wake_up_interruptible(&priv->delta_msr_wait); 786 + wake_up_interruptible(&port->delta_msr_wait); 788 787 789 788 if (!urb->actual_length) 790 789 return;
+7 -5
drivers/usb/serial/quatech2.c
··· 128 128 u8 shadowLSR; 129 129 u8 shadowMSR; 130 130 131 - wait_queue_head_t delta_msr_wait; /* Used for TIOCMIWAIT */ 132 131 struct async_icount icount; 133 132 134 133 struct usb_serial_port *port; ··· 505 506 spin_unlock_irqrestore(&priv->lock, flags); 506 507 507 508 while (1) { 508 - wait_event_interruptible(priv->delta_msr_wait, 509 - ((priv->icount.rng != prev.rng) || 509 + wait_event_interruptible(port->delta_msr_wait, 510 + (port->serial->disconnected || 511 + (priv->icount.rng != prev.rng) || 510 512 (priv->icount.dsr != prev.dsr) || 511 513 (priv->icount.dcd != prev.dcd) || 512 514 (priv->icount.cts != prev.cts))); 513 515 514 516 if (signal_pending(current)) 515 517 return -ERESTARTSYS; 518 + 519 + if (port->serial->disconnected) 520 + return -EIO; 516 521 517 522 spin_lock_irqsave(&priv->lock, flags); 518 523 cur = priv->icount; ··· 830 827 831 828 spin_lock_init(&port_priv->lock); 832 829 spin_lock_init(&port_priv->urb_lock); 833 - init_waitqueue_head(&port_priv->delta_msr_wait); 834 830 port_priv->port = port; 835 831 836 832 port_priv->write_urb = usb_alloc_urb(0, GFP_KERNEL); ··· 972 970 if (newMSR & UART_MSR_TERI) 973 971 port_priv->icount.rng++; 974 972 975 - wake_up_interruptible(&port_priv->delta_msr_wait); 973 + wake_up_interruptible(&port->delta_msr_wait); 976 974 } 977 975 } 978 976
+5 -4
drivers/usb/serial/spcp8x5.c
··· 149 149 struct spcp8x5_private { 150 150 spinlock_t lock; 151 151 enum spcp8x5_type type; 152 - wait_queue_head_t delta_msr_wait; 153 152 u8 line_control; 154 153 u8 line_status; 155 154 }; ··· 178 179 return -ENOMEM; 179 180 180 181 spin_lock_init(&priv->lock); 181 - init_waitqueue_head(&priv->delta_msr_wait); 182 182 priv->type = type; 183 183 184 184 usb_set_serial_port_data(port , priv); ··· 473 475 priv->line_status &= ~UART_STATE_TRANSIENT_MASK; 474 476 spin_unlock_irqrestore(&priv->lock, flags); 475 477 /* wake up the wait for termios */ 476 - wake_up_interruptible(&priv->delta_msr_wait); 478 + wake_up_interruptible(&port->delta_msr_wait); 477 479 478 480 if (!urb->actual_length) 479 481 return; ··· 524 526 525 527 while (1) { 526 528 /* wake up in bulk read */ 527 - interruptible_sleep_on(&priv->delta_msr_wait); 529 + interruptible_sleep_on(&port->delta_msr_wait); 528 530 529 531 /* see if a signal did it */ 530 532 if (signal_pending(current)) 531 533 return -ERESTARTSYS; 534 + 535 + if (port->serial->disconnected) 536 + return -EIO; 532 537 533 538 spin_lock_irqsave(&priv->lock, flags); 534 539 status = priv->line_status;
+7 -5
drivers/usb/serial/ssu100.c
··· 61 61 spinlock_t status_lock; 62 62 u8 shadowLSR; 63 63 u8 shadowMSR; 64 - wait_queue_head_t delta_msr_wait; /* Used for TIOCMIWAIT */ 65 64 struct async_icount icount; 66 65 }; 67 66 ··· 354 355 spin_unlock_irqrestore(&priv->status_lock, flags); 355 356 356 357 while (1) { 357 - wait_event_interruptible(priv->delta_msr_wait, 358 - ((priv->icount.rng != prev.rng) || 358 + wait_event_interruptible(port->delta_msr_wait, 359 + (port->serial->disconnected || 360 + (priv->icount.rng != prev.rng) || 359 361 (priv->icount.dsr != prev.dsr) || 360 362 (priv->icount.dcd != prev.dcd) || 361 363 (priv->icount.cts != prev.cts))); 362 364 363 365 if (signal_pending(current)) 364 366 return -ERESTARTSYS; 367 + 368 + if (port->serial->disconnected) 369 + return -EIO; 365 370 366 371 spin_lock_irqsave(&priv->status_lock, flags); 367 372 cur = priv->icount; ··· 448 445 return -ENOMEM; 449 446 450 447 spin_lock_init(&priv->status_lock); 451 - init_waitqueue_head(&priv->delta_msr_wait); 452 448 453 449 usb_set_serial_port_data(port, priv); 454 450 ··· 539 537 priv->icount.dcd++; 540 538 if (msr & UART_MSR_TERI) 541 539 priv->icount.rng++; 542 - wake_up_interruptible(&priv->delta_msr_wait); 540 + wake_up_interruptible(&port->delta_msr_wait); 543 541 } 544 542 } 545 543
+6 -4
drivers/usb/serial/ti_usb_3410_5052.c
··· 74 74 int tp_flags; 75 75 int tp_closing_wait;/* in .01 secs */ 76 76 struct async_icount tp_icount; 77 - wait_queue_head_t tp_msr_wait; /* wait for msr change */ 78 77 wait_queue_head_t tp_write_wait; 79 78 struct ti_device *tp_tdev; 80 79 struct usb_serial_port *tp_port; ··· 431 432 else 432 433 tport->tp_uart_base_addr = TI_UART2_BASE_ADDR; 433 434 tport->tp_closing_wait = closing_wait; 434 - init_waitqueue_head(&tport->tp_msr_wait); 435 435 init_waitqueue_head(&tport->tp_write_wait); 436 436 if (kfifo_alloc(&tport->write_fifo, TI_WRITE_BUF_SIZE, GFP_KERNEL)) { 437 437 kfree(tport); ··· 782 784 dev_dbg(&port->dev, "%s - TIOCMIWAIT\n", __func__); 783 785 cprev = tport->tp_icount; 784 786 while (1) { 785 - interruptible_sleep_on(&tport->tp_msr_wait); 787 + interruptible_sleep_on(&port->delta_msr_wait); 786 788 if (signal_pending(current)) 787 789 return -ERESTARTSYS; 790 + 791 + if (port->serial->disconnected) 792 + return -EIO; 793 + 788 794 cnow = tport->tp_icount; 789 795 if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr && 790 796 cnow.dcd == cprev.dcd && cnow.cts == cprev.cts) ··· 1394 1392 icount->dcd++; 1395 1393 if (msr & TI_MSR_DELTA_RI) 1396 1394 icount->rng++; 1397 - wake_up_interruptible(&tport->tp_msr_wait); 1395 + wake_up_interruptible(&tport->tp_port->delta_msr_wait); 1398 1396 spin_unlock_irqrestore(&tport->tp_lock, flags); 1399 1397 } 1400 1398
+2 -1
drivers/usb/serial/usb-serial.c
··· 151 151 } 152 152 } 153 153 154 + usb_put_intf(serial->interface); 154 155 usb_put_dev(serial->dev); 155 156 kfree(serial); 156 157 } ··· 621 620 } 622 621 serial->dev = usb_get_dev(dev); 623 622 serial->type = driver; 624 - serial->interface = interface; 623 + serial->interface = usb_get_intf(interface); 625 624 kref_init(&serial->kref); 626 625 mutex_init(&serial->disc_mutex); 627 626 serial->minor = SERIAL_TTY_NO_MINOR;
+7
drivers/usb/storage/unusual_devs.h
··· 496 496 USB_SC_DEVICE, USB_PR_DEVICE, NULL, 497 497 US_FL_MAX_SECTORS_64 | US_FL_BULK_IGNORE_TAG), 498 498 499 + /* Added by Dmitry Artamonow <mad_soft@inbox.ru> */ 500 + UNUSUAL_DEV( 0x04e8, 0x5136, 0x0000, 0x9999, 501 + "Samsung", 502 + "YP-Z3", 503 + USB_SC_DEVICE, USB_PR_DEVICE, NULL, 504 + US_FL_MAX_SECTORS_64), 505 + 499 506 /* Entry and supporting patch by Theodore Kilgore <kilgota@auburn.edu>. 500 507 * Device uses standards-violating 32-byte Bulk Command Block Wrappers and 501 508 * reports itself as "Proprietary SCSI Bulk." Cf. device entry 0x084d:0x0011.
+2
include/linux/usb/serial.h
··· 66 66 * port. 67 67 * @flags: usb serial port flags 68 68 * @write_wait: a wait_queue_head_t used by the port. 69 + * @delta_msr_wait: modem-status-change wait queue 69 70 * @work: work queue entry for the line discipline waking up. 70 71 * @throttled: nonzero if the read urb is inactive to throttle the device 71 72 * @throttle_req: nonzero if the tty wants to throttle us ··· 113 112 114 113 unsigned long flags; 115 114 wait_queue_head_t write_wait; 115 + wait_queue_head_t delta_msr_wait; 116 116 struct work_struct work; 117 117 char throttled; 118 118 char throttle_req;
+8
include/linux/usb/ulpi.h
··· 181 181 182 182 /*-------------------------------------------------------------------------*/ 183 183 184 + #if IS_ENABLED(CONFIG_USB_ULPI) 184 185 struct usb_phy *otg_ulpi_create(struct usb_phy_io_ops *ops, 185 186 unsigned int flags); 187 + #else 188 + static inline struct usb_phy *otg_ulpi_create(struct usb_phy_io_ops *ops, 189 + unsigned int flags) 190 + { 191 + return NULL; 192 + } 193 + #endif 186 194 187 195 #ifdef CONFIG_USB_ULPI_VIEWPORT 188 196 /* access ops for controllers with a viewport register */