Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 f48f3febb2cb ("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>

authored by

Florian Schmaus and committed by
Greg Kroah-Hartman
0dda2bb6 6a8b55d7

+5 -1
+5 -1
drivers/base/driver.c
··· 148 148 int ret; 149 149 struct device_driver *other; 150 150 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 + } 152 156 153 157 if ((drv->bus->probe && drv->probe) || 154 158 (drv->bus->remove && drv->remove) ||