From: Konstantin Filatov <kfilatov@xxxxxxxxxxxxx>

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



with a length that isn't multiply by max pkt size for this endpoint.

The commit 689d6eac (USB: UHCI: add native scatter-gather support(v1))
introduced an implementation of scatter-gather list for UHCI.
This implementation has a bug when the size of a non-last sg
element was not multiply by TD's max-pkt-size. This bug was latent
till the commit 2851784f (usb/uhci: initialize sg_table properly)
which really initializes sg_table and enables SG lists in UHCI.

The bug can be easily reproduced with Gadget Zero in full_speed mode
connected to a host with UHCI controller by the standard test from
tools/usb/ with command line
  testusb -a -t 7 -c 2000 -s 4096 -v 41
The test sends trash bytes to the gadget instead of only zero bytes
and so the test fails.

This patch shortens TD's packet not only for the last TD in sg list,
but also for the last TD in sg element.

Signed-off-by: Konstantin Filatov <kfilatov@xxxxxxxxxxxxx>
Signed-off-by: Denis V. Lunev <den@xxxxxxxxxx>
Acked-by: Alan Stern <stern@xxxxxxxxxxxxxxxxxxx>
CC: Ming Lei <tom.leiming@xxxxxxxxx>
CC: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx>
CC: linux-usb@xxxxxxxxxxxxxxx
---
Changes from v2:
- changed subject as suggested by Alan Stern
- edited description
- shortened the referenced commit descriptions

Changes from v1:
- added short commit descriptions as requested by Sergei Shtylyov
- CC list extended according to the list of original authors

 drivers/usb/host/uhci-q.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/usb/host/uhci-q.c b/drivers/usb/host/uhci-q.c
index 6e6ea21..e0ebc80 100644
--- a/drivers/usb/host/uhci-q.c
+++ b/drivers/usb/host/uhci-q.c
@@ -977,6 +977,9 @@ static int uhci_submit_common(struct uhci_hcd *uhci, struct urb *urb,
 	for (;;) {	/* Allow zero length packets */
 		int pktsze = maxsze;
 
+		if (this_sg_len < pktsze)	/* The short packet */
+			pktsze = this_sg_len;
+
 		if (len <= pktsze) {		/* The last packet */
 			pktsze = len;
 			if (!(urb->transfer_flags & URB_SHORT_NOT_OK))
-- 
1.8.1.5

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux