diff mbox series

power: supply: bq256xx: Handle OOM correctly

Message ID 20220110155007.1216836-1-linus.walleij@linaro.org (mailing list archive)
State Handled Elsewhere, archived
Headers show
Series power: supply: bq256xx: Handle OOM correctly | expand

Commit Message

Linus Walleij Jan. 10, 2022, 3:50 p.m. UTC
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>
---
 drivers/power/supply/bq256xx_charger.c | 3 +++
 1 file changed, 3 insertions(+)
diff mbox series

Patch

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