Skip to content

Commit 2656a9a

Browse files
AlanSterngregkh
authored andcommitted
USB: EHCI: bugfix: urb->hcpriv should not be NULL
This patch (as1632b) fixes a bug in ehci-hcd. The USB core uses urb->hcpriv to determine whether or not an URB is active; host controller drivers are supposed to set this pointer to a non-NULL value when an URB is queued. However ehci-hcd sets it to NULL for isochronous URBs, which defeats the check in usbcore. In itself this isn't a big deal. But people have recently found that certain sequences of actions will cause the snd-usb-audio driver to reuse URBs without waiting for them to complete. In the absence of proper checking by usbcore, the URBs get added to their endpoint list twice. This leads to list corruption and a system freeze. The patch makes ehci-hcd assign a meaningful value to urb->hcpriv for isochronous URBs. Improving robustness always helps. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Reported-by: Artem S. Tashkinov <t.artem@lycos.com> Reported-by: Christof Meerwald <cmeerw@cmeerw.org> CC: <stable@vger.kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 1b36810 commit 2656a9a

2 files changed

Lines changed: 5 additions & 11 deletions

File tree

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

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -264,15 +264,9 @@ ehci_urb_done(struct ehci_hcd *ehci, struct urb *urb, int status)
264264
__releases(ehci->lock)
265265
__acquires(ehci->lock)
266266
{
267-
if (likely (urb->hcpriv != NULL)) {
268-
struct ehci_qh *qh = (struct ehci_qh *) urb->hcpriv;
269-
270-
/* S-mask in a QH means it's an interrupt urb */
271-
if ((qh->hw->hw_info2 & cpu_to_hc32(ehci, QH_SMASK)) != 0) {
272-
273-
/* ... update hc-wide periodic stats (for usbfs) */
274-
ehci_to_hcd(ehci)->self.bandwidth_int_reqs--;
275-
}
267+
if (usb_pipetype(urb->pipe) == PIPE_INTERRUPT) {
268+
/* ... update hc-wide periodic stats */
269+
ehci_to_hcd(ehci)->self.bandwidth_int_reqs--;
276270
}
277271

278272
if (unlikely(urb->unlinked)) {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1630,7 +1630,7 @@ static void itd_link_urb(
16301630

16311631
/* don't need that schedule data any more */
16321632
iso_sched_free (stream, iso_sched);
1633-
urb->hcpriv = NULL;
1633+
urb->hcpriv = stream;
16341634

16351635
++ehci->isoc_count;
16361636
enable_periodic(ehci);
@@ -2029,7 +2029,7 @@ static void sitd_link_urb(
20292029

20302030
/* don't need that schedule data any more */
20312031
iso_sched_free (stream, sched);
2032-
urb->hcpriv = NULL;
2032+
urb->hcpriv = stream;
20332033

20342034
++ehci->isoc_count;
20352035
enable_periodic(ehci);

0 commit comments

Comments
 (0)