summaryrefslogtreecommitdiffstats
path: root/lib/libusb
diff options
context:
space:
mode:
authorhselasky <hselasky@FreeBSD.org>2016-09-09 06:25:40 +0000
committerhselasky <hselasky@FreeBSD.org>2016-09-09 06:25:40 +0000
commit5303a41e72409143ca5ed4abc80502f4bbb90e33 (patch)
treeec4032d690fc4ca5388e2b7822f7c39e7bafebb4 /lib/libusb
parent1a264b6c55be53aa6af99a402a6dd4910a35b2cc (diff)
downloadFreeBSD-src-5303a41e72409143ca5ed4abc80502f4bbb90e33.zip
FreeBSD-src-5303a41e72409143ca5ed4abc80502f4bbb90e33.tar.gz
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.
Diffstat (limited to 'lib/libusb')
-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 2f4ee78..91ed9d7 100644
--- a/lib/libusb/libusb20.c
+++ b/lib/libusb/libusb20.c
@@ -176,6 +176,12 @@ libusb20_tr_open_stream(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;
@@ -200,8 +206,13 @@ libusb20_tr_open_stream(struct libusb20_transfer *xfer, uint32_t MaxBufSize,
}
memset(xfer->ppBuffer, 0, size);
- error = xfer->pdev->methods->tr_open(xfer, MaxBufSize,
- MaxFrameCount, ep_no, stream_id, pre_scale);
+ if (pre_scale) {
+ error = xfer->pdev->methods->tr_open(xfer, MaxBufSize,
+ MaxFrameCount / 8, ep_no, stream_id, 1);
+ } else {
+ error = xfer->pdev->methods->tr_open(xfer, MaxBufSize,
+ MaxFrameCount, ep_no, stream_id, 0);
+ }
if (error) {
free(xfer->ppBuffer);
OpenPOWER on IntegriCloud