summaryrefslogtreecommitdiffstats
path: root/drivers/base/bus.c
diff options
context:
space:
mode:
authorDave Young <hidave.darkstar@gmail.com>2009-02-14 21:23:22 +0800
committerGreg Kroah-Hartman <gregkh@suse.de>2009-03-24 16:38:25 -0700
commitf48f3febb2cbfd0f2ecee7690835ba745c1034a4 (patch)
tree1cb3803049cde40ff3dc528a2120f915e65f0367 /drivers/base/bus.c
parente5779a583ddb9916b37cfbb916dc53ec2eaf0b9b (diff)
downloadblackbird-op-linux-f48f3febb2cbfd0f2ecee7690835ba745c1034a4.tar.gz
blackbird-op-linux-f48f3febb2cbfd0f2ecee7690835ba745c1034a4.zip
driver-core: do not register a driver with bus_type not registered
If the bus_type is not registerd, driver_register to that bus will cause oops. I found this bug when test built-in usb serial drivers (ie. aircable driver) with 'nousb' cmdline params. In this patch: 1. set the bus->p=NULL when bus_register failed and unregisterd. 2. if bus->p is NULL, driver_register BUG_ON will be triggered. Signed-off-by: Dave Young <hidave.darkstar@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/base/bus.c')
-rw-r--r--drivers/base/bus.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 8547b780bb5a..11463c00451e 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -932,6 +932,7 @@ bus_uevent_fail:
kset_unregister(&bus->p->subsys);
kfree(bus->p);
out:
+ bus->p = NULL;
return retval;
}
EXPORT_SYMBOL_GPL(bus_register);
@@ -953,6 +954,7 @@ void bus_unregister(struct bus_type *bus)
bus_remove_file(bus, &bus_attr_uevent);
kset_unregister(&bus->p->subsys);
kfree(bus->p);
+ bus->p = NULL;
}
EXPORT_SYMBOL_GPL(bus_unregister);
OpenPOWER on IntegriCloud