drivers/ps3: Fix ps3-vuart null dereference
authorColin King <colin.king@canonical.com>
Mon, 14 Sep 2015 19:35:04 +0000 (19:35 +0000)
committerMichael Ellerman <mpe@ellerman.id.au>
Tue, 29 Sep 2015 13:00:58 +0000 (23:00 +1000)
On the unlikely event that drv is null, the current code will
perform a null pointer dereference with it when printing a dev_dbg
message.  Instead, the BUG_ON check on drv should be performed
before we emit the dev_dbg message.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Geoff Levand <geoff@infradead.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
drivers/ps3/ps3-vuart.c

index d6db822bef84837402a8d31d3e142f2dd6b19c8b..632701a1d993f5f6725bedec8ff5afbf05909461 100644 (file)
@@ -1000,12 +1000,11 @@ static int ps3_vuart_probe(struct ps3_system_bus_device *dev)
        dev_dbg(&dev->core, "%s:%d\n", __func__, __LINE__);
 
        drv = ps3_system_bus_dev_to_vuart_drv(dev);
+       BUG_ON(!drv);
 
        dev_dbg(&dev->core, "%s:%d: (%s)\n", __func__, __LINE__,
                drv->core.core.name);
 
-       BUG_ON(!drv);
-
        if (dev->port_number >= PORT_COUNT) {
                BUG();
                return -EINVAL;