]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
staging: unisys: stop device registration before visorbus registration
authorBenjamin Romer <benjamin.romer@unisys.com>
Fri, 4 Sep 2015 16:01:32 +0000 (12:01 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 13 Sep 2015 16:43:41 +0000 (09:43 -0700)
In cases where visorbus is compiled directly into the kernel, if
visorbus registration fails for any reason, it is still possible for
other drivers to call visorbus_register_visor_driver(), which could
cause an oops. Prevent this by saving the result of the call to
create_bus() in a static variable, and return an error code when the bus
hasn't been registered successfully.

Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/unisys/visorbus/visorbus_main.c

index 7905ea920a4aa681d57a2570f538f27b7e3f0fe7..a272b48bab282af2f2ddbebc7cb63db5193a4882 100644 (file)
@@ -37,6 +37,8 @@ static int visorbus_debugref;
 #define POLLJIFFIES_TESTWORK         100
 #define POLLJIFFIES_NORMALCHANNEL     10
 
+static int busreg_rc = -ENODEV; /* stores the result from bus registration */
+
 static int visorbus_uevent(struct device *xdev, struct kobj_uevent_env *env);
 static int visorbus_match(struct device *xdev, struct device_driver *xdrv);
 static void fix_vbus_dev_info(struct visor_device *visordev);
@@ -863,6 +865,9 @@ int visorbus_register_visor_driver(struct visor_driver *drv)
 {
        int rc = 0;
 
+       if (busreg_rc < 0)
+               return -ENODEV; /*can't register on a nonexistent bus*/
+
        drv->driver.name = drv->name;
        drv->driver.bus = &visorbus_type;
        drv->driver.probe = visordriver_probe_device;
@@ -1262,10 +1267,8 @@ remove_bus_instance(struct visor_device *dev)
 static int
 create_bus_type(void)
 {
-       int rc = 0;
-
-       rc = bus_register(&visorbus_type);
-       return rc;
+       busreg_rc = bus_register(&visorbus_type);
+       return busreg_rc;
 }
 
 /** Remove the one-and-only one instance of the visor bus type (visorbus_type).