diff options
author | Dave Young <hidave.darkstar@gmail.com> | 2009-02-14 08:23:22 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2009-03-24 19:38:25 -0400 |
commit | f48f3febb2cbfd0f2ecee7690835ba745c1034a4 (patch) | |
tree | 1cb3803049cde40ff3dc528a2120f915e65f0367 /drivers/base/driver.c | |
parent | e5779a583ddb9916b37cfbb916dc53ec2eaf0b9b (diff) |
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/driver.c')
-rw-r--r-- | drivers/base/driver.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/base/driver.c b/drivers/base/driver.c index 1e2bda780e48..2889ad57e48b 100644 --- a/drivers/base/driver.c +++ b/drivers/base/driver.c | |||
@@ -216,6 +216,8 @@ int driver_register(struct device_driver *drv) | |||
216 | int ret; | 216 | int ret; |
217 | struct device_driver *other; | 217 | struct device_driver *other; |
218 | 218 | ||
219 | BUG_ON(!drv->bus->p); | ||
220 | |||
219 | if ((drv->bus->probe && drv->probe) || | 221 | if ((drv->bus->probe && drv->probe) || |
220 | (drv->bus->remove && drv->remove) || | 222 | (drv->bus->remove && drv->remove) || |
221 | (drv->bus->shutdown && drv->shutdown)) | 223 | (drv->bus->shutdown && drv->shutdown)) |