Skip to content

Commit

Permalink
driver-core: return EINVAL error instead of BUG_ON()
Browse files Browse the repository at this point in the history
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 <flo@geekplace.eu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Florian Schmaus authored and Greg Kroah-Hartman committed May 25, 2018
1 parent 6a8b55d commit 0dda2bb
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion drivers/base/driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,11 @@ int driver_register(struct device_driver *drv)
int ret;
struct device_driver *other;

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

if ((drv->bus->probe && drv->probe) ||
(drv->bus->remove && drv->remove) ||
Expand Down

0 comments on commit 0dda2bb

Please sign in to comment.