svn commit: r191398 - head/sys/dev/usb
Andrew Thompson
thompsa at FreeBSD.org
Wed Apr 22 17:08:09 UTC 2009
Author: thompsa
Date: Wed Apr 22 17:08:04 2009
New Revision: 191398
URL: http://svn.freebsd.org/changeset/base/191398
Log:
MFp4 //depot/projects/usb at 160655
Fix possible issue with clear-stall and set-config happening at the same time.
Submitted by: Hans Petter Selasky
Modified:
head/sys/dev/usb/usb_device.c
Modified: head/sys/dev/usb/usb_device.c
==============================================================================
--- head/sys/dev/usb/usb_device.c Wed Apr 22 17:07:59 2009 (r191397)
+++ head/sys/dev/usb/usb_device.c Wed Apr 22 17:08:04 2009 (r191398)
@@ -724,22 +724,33 @@ usb2_config_parse(struct usb2_device *ud
goto done;
}
}
- udev->pipes_max = ep_max;
- udev->pipes = NULL;
- if (udev->pipes_max != 0) {
- udev->pipes = malloc(sizeof(*pipe) * udev->pipes_max,
+ if (ep_max != 0) {
+ udev->pipes = malloc(sizeof(*pipe) * ep_max,
M_USB, M_WAITOK | M_ZERO);
if (udev->pipes == NULL) {
err = USB_ERR_NOMEM;
goto done;
}
+ } else {
+ udev->pipes = NULL;
}
+ USB_BUS_LOCK(udev->bus);
+ udev->pipes_max = ep_max;
+ /* reset any ongoing clear-stall */
+ udev->pipe_curr = NULL;
+ USB_BUS_UNLOCK(udev->bus);
}
done:
if (err) {
if (cmd == USB_CFG_ALLOC) {
cleanup:
+ USB_BUS_LOCK(udev->bus);
+ udev->pipes_max = 0;
+ /* reset any ongoing clear-stall */
+ udev->pipe_curr = NULL;
+ USB_BUS_UNLOCK(udev->bus);
+
/* cleanup */
if (udev->ifaces != NULL)
free(udev->ifaces, M_USB);
@@ -749,7 +760,6 @@ cleanup:
udev->ifaces = NULL;
udev->pipes = NULL;
udev->ifaces_max = 0;
- udev->pipes_max = 0;
}
}
return (err);
More information about the svn-src-head
mailing list