From: Linus Walleij Date: Mon, 10 Jan 2022 15:50:07 +0000 (+0100) Subject: power: supply: bq256xx: Handle OOM correctly X-Git-Tag: v6.6.17~8155^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f444578d727a0ca4a72b19cd4a1d7da9f1fb99fe;p=platform%2Fkernel%2Flinux-rpi.git power: supply: bq256xx: Handle OOM correctly Since we now return a pointer to an allocated object we need to account for memory allocation failure in a separate error path. Fixes: 25fd330370ac ("power: supply_core: Pass pointer to battery info") Reported-by: Dan Carpenter Signed-off-by: Linus Walleij Signed-off-by: Sebastian Reichel --- diff --git a/drivers/power/supply/bq256xx_charger.c b/drivers/power/supply/bq256xx_charger.c index b274942..01ad84f 100644 --- a/drivers/power/supply/bq256xx_charger.c +++ b/drivers/power/supply/bq256xx_charger.c @@ -1523,6 +1523,9 @@ static int bq256xx_hw_init(struct bq256xx_device *bq) BQ256XX_WDT_BIT_SHIFT); ret = power_supply_get_battery_info(bq->charger, &bat_info); + if (ret == -ENOMEM) + return ret; + if (ret) { dev_warn(bq->dev, "battery info missing, default values will be applied\n");