Fixes: 5b6f9b95f7ae ("staging: unisys: visorbus: get rid of create_bus_type.")
Kernel day0 testing robot reported a kernel BUG at drivers/base/driver.c!
with the following call stack:
[ 14.963563] [ cut here ]
[ 14.967298] kernel BUG at drivers/base/driver.c:153!
[ 14.970948] invalid opcode: [#1] SMP
[ 14.974013] CPU: 0 PID: 1 Comm: swapper/0 Not tainted
4.11.0-rc4-00790-g0789e2c #1
[ 14.978221] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS
1.9.3-20161025_171302-gandalf 04/01/2014
[ 14.983417] task: 88001ea46040 task.stack: c9008000
[ 14.987315] RIP: 0010:driver_register+0xa1/0xd0
[ 14.990044] RSP: :c900be60 EFLAGS: 00010246
[ 14.993039] RAX: RBX: 831d4c20 RCX:
[ 14.997040] RDX: 004d RSI: 831d47c0 RDI: 831d4c20
[ 15.001511] RBP: c900be78 R08: c900be78 R09: c900be7c
[ 15.006163] R10: R11: 0001 R12:
[ 15.010068] R13: R14: 832f3923 R15:
[ 15.013715] FS: () GS:88001fa0()
knlGS:
[ 15.017460] CS: 0010 DS: ES: CR0: 80050033
[ 15.021268] CR2: CR3: 03009000 CR4: 06b0
[ 15.025633] Call Trace:
[ 15.028069] ? visorbus_register_visor_driver+0x3f/0x60
[ 15.031065] ? init_unisys+0x3a/0x90
[ 15.033562] ? device_resume_response+0x50/0x50
[ 15.036083] visorinput_init+0x10/0x20
[ 15.038937] do_one_initcall+0x9a/0x164
[ 15.041838] ? set_debug_rodata+0x12/0x12
[ 15.045333] kernel_init_freeable+0x11e/0x1a1
[ 15.048369] ? rest_init+0x80/0x80
[ 15.050813] kernel_init+0x9/0x100
[ 15.053353] ret_from_fork+0x2c/0x40
[ 15.056009] Code: ff 85 c0 41 89 c4 75 13 48 8b 7b 70 31 f6 e8 97 16 be ff
44 89 e0 5b 41 5c 5d c3 48 89 df e8 57 e1 ff ff 44 89 e0 5b 41 5c 5d c3 <0f> 0b
48 8b 33 48 c7 c7 a0 dd d5 82 e8 ec f0 6f ff 48 8b 73 08
[ 15.065144] RIP: driver_register+0xa1/0xd0 RSP: c900be60
[ 15.068360] ---[ end trace 7d13369c38d80a8f ]---
This bug will occur if the visorbus driver is built-in to the kernel, and
the resulting kernel is run in an environment where visorbus devices are
NOT supported, and an attempt is made to load any of the drivers: visorhba,
visornic, or visorinput.
Checked to see if we have called bus_register, if not do not call
driver_register.
Signed-off-by: David Kershner
Reviewed-by: Tim Sell
---
- Changes from v1 - Made changes suggested by GregKH. Instead of reverting
patch, just added the check for initialization.
drivers/staging/unisys/visorbus/visorbus_main.c | 6 ++
1 file changed, 6 insertions(+)
diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c
b/drivers/staging/unisys/visorbus/visorbus_main.c
index 4348072..9490977 100644
--- a/drivers/staging/unisys/visorbus/visorbus_main.c
+++ b/drivers/staging/unisys/visorbus/visorbus_main.c
@@ -29,6 +29,7 @@
#define CURRENT_FILE_PC VISOR_BUS_PC_visorbus_main_c
#define POLLJIFFIES_NORMALCHANNEL 10
+static bool initialized; /* stores whether bus_registration was successful */
static struct dentry *visorbus_debugfs_dir;
/*
@@ -959,6 +960,9 @@ static void bus_device_info_init(
*/
int visorbus_register_visor_driver(struct visor_driver *drv)
{
+ if (!initialized)
+ return -ENODEV; /*can't register on a nonexistent bus*/
+
drv->driver.name = drv->name;
drv->driver.bus = _type;
drv->driver.probe = visordriver_probe_device;
@@ -1297,6 +1301,7 @@ int visorbus_register_visor_driver(struct visor_driver
*drv)
POSTCODE_LINUX(BUS_CREATE_ENTRY_PC, 0, 0, DIAG_SEVERITY_ERR);
goto error;
}
+ initialized = true;
bus_device_info_init(_driverinfo, "chipset", "visorchipset");
@@ -1322,5 +1327,6 @@ int visorbus_register_visor_driver(struct visor_driver
*drv)
}
bus_unregister(_type);
+ initialized = false;
debugfs_remove_recursive(visorbus_debugfs_dir);
}
--
1.9.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel