]> git.baikalelectronics.ru Git - kernel.git/commitdiff
power: supply: bq256xx: Handle OOM correctly
authorLinus Walleij <linus.walleij@linaro.org>
Mon, 10 Jan 2022 15:50:07 +0000 (16:50 +0100)
committerSebastian Reichel <sebastian.reichel@collabora.com>
Fri, 11 Feb 2022 20:19:51 +0000 (21:19 +0100)
Since we now return a pointer to an allocated object we need
to account for memory allocation failure in a separate
error path.

Fixes: f7a2564b4fdd ("power: supply_core: Pass pointer to battery info")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
drivers/power/supply/bq256xx_charger.c

index b274942dc46a38db5cb533f54f2e87a16822b287..01ad84fd147c8ab131a2f36a130f81c90bcdca40 100644 (file)
@@ -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");