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: 25fd330370 ("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>
This commit is contained in:
Linus Walleij 2022-01-10 16:50:07 +01:00 коммит произвёл Sebastian Reichel
Родитель 2b56a9a28a
Коммит f444578d72
1 изменённых файлов: 3 добавлений и 0 удалений

Просмотреть файл

@ -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");