1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-02-06 18:29:47 +00:00

MFp4 //depot/projects/usb@160655

Fix possible issue with clear-stall and set-config happening at the same time.

Submitted by:	Hans Petter Selasky
This commit is contained in:
Andrew Thompson 2009-04-22 17:08:04 +00:00
parent 88b4e0abcf
commit 9469c92974
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=191398

View File

@ -724,22 +724,33 @@ usb2_config_parse(struct usb2_device *udev, uint8_t iface_index, uint8_t cmd)
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);