aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Petter Selasky <hselasky@FreeBSD.org>2016-09-09 06:33:56 +0000
committerHans Petter Selasky <hselasky@FreeBSD.org>2016-09-09 06:33:56 +0000
commit5b4770cc138cd9160eef62a0df9c3ff65e241532 (patch)
tree741a7fac8bb64d74230c1738046be26779c9a12b
parentdd17db0b09f1fbbd30adfffce47ac46b2db15a5c (diff)
downloadsrc-5b4770cc138cd9160eef62a0df9c3ff65e241532.tar.gz
src-5b4770cc138cd9160eef62a0df9c3ff65e241532.zip
MFC r305284:
Fix array size issue when using the pre-scaling feature for ISOCHRONOUS USB transfers. Make sure enough length and buffer pointers are allocated when setting up the libusb transfer structure to support the maximum number of frames the kernel can handle.
Notes
Notes: svn path=/stable/8/; revision=305643
-rw-r--r--lib/libusb/libusb20.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/libusb/libusb20.c b/lib/libusb/libusb20.c
index 75af7a1865c1..2c76653e9bd3 100644
--- a/lib/libusb/libusb20.c
+++ b/lib/libusb/libusb20.c
@@ -163,6 +163,12 @@ libusb20_tr_open(struct libusb20_transfer *xfer, uint32_t MaxBufSize,
return (LIBUSB20_ERROR_BUSY);
if (MaxFrameCount & LIBUSB20_MAX_FRAME_PRE_SCALE) {
MaxFrameCount &= ~LIBUSB20_MAX_FRAME_PRE_SCALE;
+ /*
+ * The kernel can setup 8 times more frames when
+ * pre-scaling ISOCHRONOUS transfers. Make sure the
+ * length and pointer buffers are big enough:
+ */
+ MaxFrameCount *= 8;
pre_scale = 1;
} else {
pre_scale = 0;
@@ -187,8 +193,13 @@ libusb20_tr_open(struct libusb20_transfer *xfer, uint32_t MaxBufSize,
}
memset(xfer->ppBuffer, 0, size);
- error = xfer->pdev->methods->tr_open(xfer, MaxBufSize,
- MaxFrameCount, ep_no, pre_scale);
+ if (pre_scale) {
+ error = xfer->pdev->methods->tr_open(xfer, MaxBufSize,
+ MaxFrameCount / 8, ep_no, 1);
+ } else {
+ error = xfer->pdev->methods->tr_open(xfer, MaxBufSize,
+ MaxFrameCount, ep_no, 0);
+ }
if (error) {
free(xfer->ppBuffer);