mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-03 17:40:04 +00:00
greybus: don't assume subdevs are valid
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>
This commit is contained in:
parent
8fd39e3dcb
commit
051fb04712
4 changed files with 9 additions and 1 deletions
|
@ -135,6 +135,8 @@ void gb_battery_disconnect(struct gb_module *gmod)
|
||||||
struct gb_battery *gb;
|
struct gb_battery *gb;
|
||||||
|
|
||||||
gb = gmod->gb_battery;
|
gb = gmod->gb_battery;
|
||||||
|
if (!gb)
|
||||||
|
return;
|
||||||
|
|
||||||
power_supply_unregister(&gb->bat);
|
power_supply_unregister(&gb->bat);
|
||||||
|
|
||||||
|
|
|
@ -92,6 +92,8 @@ void gb_gpio_disconnect(struct gb_module *gmod)
|
||||||
int retval;
|
int retval;
|
||||||
|
|
||||||
gb_gpio_dev = gmod->gb_gpio_dev;
|
gb_gpio_dev = gmod->gb_gpio_dev;
|
||||||
|
if (!gb_gpio_dev)
|
||||||
|
return;
|
||||||
|
|
||||||
retval = gpiochip_remove(&gb_gpio_dev->chip);
|
retval = gpiochip_remove(&gb_gpio_dev->chip);
|
||||||
kfree(gb_gpio_dev);
|
kfree(gb_gpio_dev);
|
||||||
|
|
|
@ -121,6 +121,8 @@ void gb_i2c_disconnect(struct gb_module *gmod)
|
||||||
struct gb_i2c_device *gb_i2c_dev;
|
struct gb_i2c_device *gb_i2c_dev;
|
||||||
|
|
||||||
gb_i2c_dev = gmod->gb_i2c_dev;
|
gb_i2c_dev = gmod->gb_i2c_dev;
|
||||||
|
if (!gb_i2c_dev)
|
||||||
|
return;
|
||||||
i2c_del_adapter(gb_i2c_dev->adapter);
|
i2c_del_adapter(gb_i2c_dev->adapter);
|
||||||
kfree(gb_i2c_dev->adapter);
|
kfree(gb_i2c_dev->adapter);
|
||||||
kfree(gb_i2c_dev);
|
kfree(gb_i2c_dev);
|
||||||
|
|
|
@ -71,8 +71,10 @@ void gb_sdio_disconnect(struct gb_module *gmod)
|
||||||
struct gb_sdio_host *host;
|
struct gb_sdio_host *host;
|
||||||
|
|
||||||
host = gmod->gb_sdio_host;
|
host = gmod->gb_sdio_host;
|
||||||
mmc = host->mmc;
|
if (!host)
|
||||||
|
return;
|
||||||
|
|
||||||
|
mmc = host->mmc;
|
||||||
mmc_remove_host(mmc);
|
mmc_remove_host(mmc);
|
||||||
mmc_free_host(mmc);
|
mmc_free_host(mmc);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue