Commit f48f3febb2cbfd0f2ecee7690835ba745c1034a4
Committed by
Greg Kroah-Hartman
1 parent
e5779a583d
Exists in
master
and in
7 other branches
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>
Showing 2 changed files with 4 additions and 0 deletions Side-by-side Diff
drivers/base/bus.c
... | ... | @@ -932,6 +932,7 @@ |
932 | 932 | kset_unregister(&bus->p->subsys); |
933 | 933 | kfree(bus->p); |
934 | 934 | out: |
935 | + bus->p = NULL; | |
935 | 936 | return retval; |
936 | 937 | } |
937 | 938 | EXPORT_SYMBOL_GPL(bus_register); |
... | ... | @@ -953,6 +954,7 @@ |
953 | 954 | bus_remove_file(bus, &bus_attr_uevent); |
954 | 955 | kset_unregister(&bus->p->subsys); |
955 | 956 | kfree(bus->p); |
957 | + bus->p = NULL; | |
956 | 958 | } |
957 | 959 | EXPORT_SYMBOL_GPL(bus_unregister); |
958 | 960 |
drivers/base/driver.c