# This is a BitKeeper generated patch for the following project:
# Project Name: Linux kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher.
# This patch includes the following deltas:
#	           ChangeSet	1.513.3.4 -> 1.513.3.5
#	drivers/usb/core/usb.c	1.49    -> 1.50   
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 02/05/06	oliver@neukum.name	1.513.3.5
# [PATCH] usage count handling during disconnect
# 
# in usb.c during disconnect handling a reference to a driver is passed
# after the module usage count is decremented. In theory this is a race.
# --------------------------------------------
#
diff -Nru a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
--- a/drivers/usb/core/usb.c	Tue May  7 15:18:20 2002
+++ b/drivers/usb/core/usb.c	Tue May  7 15:18:20 2002
@@ -1899,11 +1899,12 @@
 				down(&driver->serialize);
 				driver->disconnect(dev, interface->private_data);
 				up(&driver->serialize);
-				if (driver->owner)
-					__MOD_DEC_USE_COUNT(driver->owner);
 				/* if driver->disconnect didn't release the interface */
 				if (interface->driver)
 					usb_driver_release_interface(driver, interface);
+				/* we don't need the driver any longer */
+				if (driver->owner)
+					__MOD_DEC_USE_COUNT(driver->owner);
 			}
 			/* remove our device node for this interface */
 			put_device(&interface->dev);
