Skip to content

Commit 0dda2bb

Browse files
Flowdalicgregkh
authored andcommitted
driver-core: return EINVAL error instead of BUG_ON()
I triggerd the BUG_ON() in driver_register() when booting a domU Xen domain. Since there was no contextual information logged, I needed to attach kgdb to determine the culprit (the wmi-bmof driver in my case). The BUG_ON() was added in commit f48f3fe ("driver-core: do not register a driver with bus_type not registered"). Instead of running into a BUG_ON() we print an error message identifying the, likely faulty, driver but continue booting. Signed-off-by: Florian Schmaus <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 6a8b55d commit 0dda2bb

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

drivers/base/driver.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,11 @@ int driver_register(struct device_driver *drv)
148148
int ret;
149149
struct device_driver *other;
150150

151-
BUG_ON(!drv->bus->p);
151+
if (!drv->bus->p) {
152+
pr_err("Driver '%s' was unable to register with bus_type '%s' because the bus was not initialized.\n",
153+
drv->name, drv->bus->name);
154+
return -EINVAL;
155+
}
152156

153157
if ((drv->bus->probe && drv->probe) ||
154158
(drv->bus->remove && drv->remove) ||

0 commit comments

Comments
 (0)