Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 21 Dec 2011 08:46:08 +0000 (UTC)
From:      Hans Petter Selasky <hselasky@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r228758 - head/sys/dev/usb
Message-ID:  <201112210846.pBL8k8NG057639@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: hselasky
Date: Wed Dec 21 08:46:08 2011
New Revision: 228758
URL: http://svn.freebsd.org/changeset/base/228758

Log:
  Fix for race against user-space applications trying to change the
  configuration on USB HUBs.
  
  PR:		kern/163091
  MFC after:	1 week

Modified:
  head/sys/dev/usb/usb_hub.c

Modified: head/sys/dev/usb/usb_hub.c
==============================================================================
--- head/sys/dev/usb/usb_hub.c	Wed Dec 21 02:45:51 2011	(r228757)
+++ head/sys/dev/usb/usb_hub.c	Wed Dec 21 08:46:08 2011	(r228758)
@@ -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;
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201112210846.pBL8k8NG057639>