summaryrefslogtreecommitdiff
path: root/drivers/power/supply
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2022-01-10 16:50:07 +0100
committerSebastian Reichel <sebastian.reichel@collabora.com>2022-02-11 21:19:51 +0100
commitf444578d727a0ca4a72b19cd4a1d7da9f1fb99fe (patch)
tree2feeb4d8be45d811752a3ad6b230adcb36aa8f2b /drivers/power/supply
parent2b56a9a28a6bf09890a43161402948ed62963f36 (diff)
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 <dan.carpenter@oracle.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Diffstat (limited to 'drivers/power/supply')
-rw-r--r--drivers/power/supply/bq256xx_charger.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/power/supply/bq256xx_charger.c b/drivers/power/supply/bq256xx_charger.c
index b274942dc46a..01ad84fd147c 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");