From 888a09bbb454a6d5020219d64ff272402c890111 Mon Sep 17 00:00:00 2001 From: hselasky Date: Sat, 31 Dec 2011 14:24:22 +0000 Subject: [PATCH] MFC r228758: Fix for race against user-space applications trying to change the configuration on USB HUBs. PR: kern/163091 git-svn-id: svn://svn.freebsd.org/base/stable/9@229097 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- sys/dev/usb/usb_hub.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/sys/dev/usb/usb_hub.c b/sys/dev/usb/usb_hub.c index 5795d56bf..f48e5058c 100644 --- a/sys/dev/usb/usb_hub.c +++ b/sys/dev/usb/usb_hub.c @@ -707,6 +707,13 @@ uhub_explore(struct usb_device *udev) DPRINTF("Device is suspended!\n"); return (0); } + + /* + * Make sure we don't race against user-space applications + * like LibUSB: + */ + usbd_enum_lock(udev); + for (x = 0; x != hub->nports; x++) { up = hub->ports + x; portno = x + 1; @@ -784,6 +791,8 @@ uhub_explore(struct usb_device *udev) up->restartcnt = 0; } + usbd_enum_unlock(udev); + /* initial status checked */ sc->sc_flags |= UHUB_FLAG_DID_EXPLORE; -- 2.45.0