Skip to content

Commit f026058

Browse files
matnymangregkh
authored andcommitted
xhci: Set correct transferred length for cancelled bulk transfers
The transferred length is set incorrectly for cancelled bulk transfer TDs in case the bulk transfer ring stops on the last transfer block with a 'Stop - Length Invalid' completion code. length essentially ends up being set to the requested length: urb->actual_length = urb->transfer_buffer_length Length for 'Stop - Length Invalid' cases should be the sum of all TRB transfer block lengths up to the one the ring stopped on, _excluding_ the one stopped on. Fix this by always summing up TRB lengths for 'Stop - Length Invalid' bulk cases. This issue was discovered by Alan Stern while debugging https://bugzilla.kernel.org/show_bug.cgi?id=218890, but does not solve that bug. Issue is older than 4.10 kernel but fix won't apply to those due to major reworks in that area. Tested-by: Pierre Tomon <[email protected]> Cc: [email protected] # v4.10+ Cc: Alan Stern <[email protected]> Signed-off-by: Mathias Nyman <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 1092c41 commit f026058

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

drivers/usb/host/xhci-ring.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2524,9 +2524,8 @@ static int process_bulk_intr_td(struct xhci_hcd *xhci, struct xhci_virt_ep *ep,
25242524
goto finish_td;
25252525
case COMP_STOPPED_LENGTH_INVALID:
25262526
/* stopped on ep trb with invalid length, exclude it */
2527-
ep_trb_len = 0;
2528-
remaining = 0;
2529-
break;
2527+
td->urb->actual_length = sum_trb_lengths(xhci, ep_ring, ep_trb);
2528+
goto finish_td;
25302529
case COMP_USB_TRANSACTION_ERROR:
25312530
if (xhci->quirks & XHCI_NO_SOFT_RETRY ||
25322531
(ep->err_count++ > MAX_SOFT_RETRY) ||

0 commit comments

Comments
 (0)