# 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.576   -> 1.577  
#	 drivers/base/core.c	1.36    -> 1.37   
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 02/09/16	greg@kroah.com	1.577
# Driver Model: fix oops when device is removed from system
# --------------------------------------------
#
diff -Nru a/drivers/base/core.c b/drivers/base/core.c
--- a/drivers/base/core.c	Mon Sep 16 15:00:46 2002
+++ b/drivers/base/core.c	Mon Sep 16 15:00:46 2002
@@ -103,12 +103,13 @@
 		devclass_remove_device(dev);
 		spin_lock(&device_lock);
 		drv = dev->driver;
-		dev->driver = NULL;
 		spin_unlock(&device_lock);
 
 		/* detach from driver */
 		if (drv && drv->remove)
 			drv->remove(dev);
+
+		dev->driver = NULL;
 	}
 }
 
