staging: unisys: prevent faults processing messages
authorTim Sell <Timothy.Sell@unisys.com>
Thu, 9 Jul 2015 17:27:42 +0000 (13:27 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 15 Jul 2015 01:34:58 +0000 (18:34 -0700)
Prevent faults processing messages for devices that no driver has yet
registered to handle.

Previously, code of the form:

    drv = to_visor_driver(dev->device.driver);
    if (!drv)
        goto away;

was not having the desired intent, because to_visor_driver() was
essentially returning garbage if its argument was NULL.  The only existing
case of this is in initiate_chipset_device_pause_resume(), which is called
during IOVM service partition recovery.  We were thus faulting when IOVM
service partition recovery was initiated on a bus that had at least one
device for which no function driver had registered
(visorbus_register_visor_driver).

Signed-off-by: Tim Sell <Timothy.Sell@unisys.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/unisys/include/visorbus.h

index e4a21e42e868c2bfdd3c6f748883636956cb6e78..a0144c6a8ad18e959a3bcaab35bb290551bd326e 100644 (file)
@@ -113,7 +113,8 @@ struct visor_driver {
        struct driver_attribute version_attr;
 };
 
-#define to_visor_driver(x) container_of(x, struct visor_driver, driver)
+#define to_visor_driver(x) ((x) ? \
+       (container_of(x, struct visor_driver, driver)) : (NULL))
 
 /** A device type for things "plugged" into the visorbus bus */
 
This page took 0.025082 seconds and 5 git commands to generate.