svn commit: r305642 - stable/9/lib/libusb

Hans Petter Selasky hselasky at FreeBSD.org
Fri Sep 9 06:31:26 UTC 2016


Author: hselasky
Date: Fri Sep  9 06:31:25 2016
New Revision: 305642
URL: https://svnweb.freebsd.org/changeset/base/305642

Log:
  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.

Modified:
  stable/9/lib/libusb/libusb20.c
Directory Properties:
  stable/9/lib/   (props changed)
  stable/9/lib/libusb/   (props changed)

Modified: stable/9/lib/libusb/libusb20.c
==============================================================================
--- stable/9/lib/libusb/libusb20.c	Fri Sep  9 06:27:25 2016	(r305641)
+++ stable/9/lib/libusb/libusb20.c	Fri Sep  9 06:31:25 2016	(r305642)
@@ -165,6 +165,12 @@ libusb20_tr_open(struct libusb20_transfe
 		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;
@@ -189,8 +195,13 @@ libusb20_tr_open(struct libusb20_transfe
 	}
 	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);


More information about the svn-src-stable-9 mailing list