summaryrefslogtreecommitdiffstats
path: root/sys/dev/usb/xhci.c
diff options
context:
space:
mode:
authormglocker <mglocker@openbsd.org>2019-11-18 20:25:49 +0000
committermglocker <mglocker@openbsd.org>2019-11-18 20:25:49 +0000
commit5ee1ceac012ee81aeae94710e89dfc14c2ff37b0 (patch)
treed2b7b900496a3f89d79632ba089b74f45ce3c42c /sys/dev/usb/xhci.c
parentFix actual length calculation of short transfers in xhci(4). So far (diff)
downloadwireguard-openbsd-5ee1ceac012ee81aeae94710e89dfc14c2ff37b0.tar.xz
wireguard-openbsd-5ee1ceac012ee81aeae94710e89dfc14c2ff37b0.zip
Fix off-by-one TRB issue in bulk transfers larger than 64k.
This makes udl(4) on xhci(4) work fine. Help and ok patrick@
Diffstat (limited to 'sys/dev/usb/xhci.c')
-rw-r--r--sys/dev/usb/xhci.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/sys/dev/usb/xhci.c b/sys/dev/usb/xhci.c
index 0e27cacc34c..064235b2841 100644
--- a/sys/dev/usb/xhci.c
+++ b/sys/dev/usb/xhci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: xhci.c,v 1.107 2019/11/18 20:08:49 patrick Exp $ */
+/* $OpenBSD: xhci.c,v 1.108 2019/11/18 20:25:49 mglocker Exp $ */
/*
* Copyright (c) 2014-2015 Martin Pieuchot
@@ -2900,7 +2900,7 @@ xhci_device_generic_start(struct usbd_xfer *xfer)
/* If the buffer crosses a 64k boundary, we need one more. */
len = XHCI_TRB_MAXSIZE - (paddr & (XHCI_TRB_MAXSIZE - 1));
if (len < xfer->length)
- ntrb++;
+ ntrb = howmany(xfer->length - len, XHCI_TRB_MAXSIZE) + 1;
else
len = xfer->length;