USB: EHCI: fix for leaking isochronous data
authorAlan Stern <[email protected]>
Wed, 30 Jan 2013 21:35:02 +0000 (16:35 -0500)
committerGreg Kroah-Hartman <[email protected]>
Thu, 31 Jan 2013 09:14:48 +0000 (10:14 +0100)
This patch (as1653) fixes a bug in ehci-hcd.  Unlike iTD entries, an
siTD entry in the periodic schedule may not complete until the frame
after the one it belongs to.  Consequently, when scanning the periodic
schedule it is necessary to start with the frame _preceding_ the one
where the previous scan ended.

Not doing this properly can result in memory leaks and failures to
complete isochronous URBs.

Signed-off-by: Alan Stern <[email protected]>
Reported-by: Andy Leiserson <[email protected]>
Cc: stable <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
drivers/usb/host/ehci-sched.c

index 69ebee73c0c153581895dbd7860ab75024784394..2b6917dc399679242f548819e148c630d9d69232 100644 (file)
@@ -2212,11 +2212,11 @@ static void scan_isoc(struct ehci_hcd *ehci)
        }
        ehci->now_frame = now_frame;
 
+       frame = ehci->last_iso_frame;
        for (;;) {
                union ehci_shadow       q, *q_p;
                __hc32                  type, *hw_p;
 
-               frame = ehci->last_iso_frame;
 restart:
                /* scan each element in frame's queue for completions */
                q_p = &ehci->pshadow [frame];
@@ -2321,6 +2321,9 @@ restart:
                /* Stop when we have reached the current frame */
                if (frame == now_frame)
                        break;
-               ehci->last_iso_frame = (frame + 1) & fmask;
+
+               /* The last frame may still have active siTDs */
+               ehci->last_iso_frame = frame;
+               frame = (frame + 1) & fmask;
        }
 }