Date: Wed, 22 Apr 2009 17:08:04 +0000 (UTC) From: Andrew Thompson <thompsa@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r191398 - head/sys/dev/usb Message-ID: <200904221708.n3MH847w062683@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
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@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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200904221708.n3MH847w062683>