Skip to content

Commit

Permalink
power: supply: bq256xx: Handle OOM correctly
Browse files Browse the repository at this point in the history
Since we now return a pointer to an allocated object we need
to account for memory allocation failure in a separate
error path.

Fixes: 25fd330 ("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>
  • Loading branch information
Linus Walleij authored and Sebastian Reichel committed Feb 11, 2022
1 parent 2b56a9a commit f444578
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/power/supply/bq256xx_charger.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down

0 comments on commit f444578

Please sign in to comment.