]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commitdiff
greybus: don't assume subdevs are valid
authorAlex Elder <elder@linaro.org>
Thu, 16 Oct 2014 11:35:24 +0000 (06:35 -0500)
committerGreg Kroah-Hartman <greg@kroah.com>
Fri, 17 Oct 2014 16:11:59 +0000 (18:11 +0200)
Most of the disconnect routines for the "subdevs" of a module
blindly assume that initialization of the subdev was successful.

Fix this by checking for null pointers.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
drivers/staging/greybus/battery-gb.c
drivers/staging/greybus/gpio-gb.c
drivers/staging/greybus/i2c-gb.c
drivers/staging/greybus/sdio-gb.c

index 1ef2f17623b0b69e2c4da5d8eb4e76570a7fa3ea..eaced9ab39d8e404aa6fc206445ed13cc8e9b25f 100644 (file)
@@ -135,6 +135,8 @@ void gb_battery_disconnect(struct gb_module *gmod)
        struct gb_battery *gb;
 
        gb = gmod->gb_battery;
+       if (!gb)
+               return;
 
        power_supply_unregister(&gb->bat);
 
index 2369175bf0f99d8640afc3d3ef4a2ca01e2b9802..da20028e7c468bc66a870179e464d5a80fc979e1 100644 (file)
@@ -92,6 +92,8 @@ void gb_gpio_disconnect(struct gb_module *gmod)
        int retval;
 
        gb_gpio_dev = gmod->gb_gpio_dev;
+       if (!gb_gpio_dev)
+               return;
 
        retval = gpiochip_remove(&gb_gpio_dev->chip);
        kfree(gb_gpio_dev);
index c01f41b59c55bb3f687d9d63556651fbd9174502..0da195898ad43dd2ee510248054937138941277b 100644 (file)
@@ -121,6 +121,8 @@ void gb_i2c_disconnect(struct gb_module *gmod)
        struct gb_i2c_device *gb_i2c_dev;
 
        gb_i2c_dev = gmod->gb_i2c_dev;
+       if (!gb_i2c_dev)
+               return;
        i2c_del_adapter(gb_i2c_dev->adapter);
        kfree(gb_i2c_dev->adapter);
        kfree(gb_i2c_dev);
index f7e80abcc0a0a6298f877cc64fb34cfd94c69d05..239fcf773acb4cc9132ccad971b7b8b5d8722dc5 100644 (file)
@@ -71,8 +71,10 @@ void gb_sdio_disconnect(struct gb_module *gmod)
        struct gb_sdio_host *host;
 
        host = gmod->gb_sdio_host;
-       mmc = host->mmc;
+       if (!host)
+               return;
 
+       mmc = host->mmc;
        mmc_remove_host(mmc);
        mmc_free_host(mmc);
 }