diff mbox series

power: supply: ab8500: Fix the error handling path of ab8500_charger_probe()

Message ID 24a8b7e7b7b8f9f4b8eaad6707f420d55fd10aac.1640722789.git.christophe.jaillet@wanadoo.fr
State Accepted
Commit be2c0d5418b1f44b01154a71e4501de139d0a7c9
Headers show
Series power: supply: ab8500: Fix the error handling path of ab8500_charger_probe() | expand

Commit Message

Christophe JAILLET Dec. 28, 2021, 8:43 p.m. UTC
Since the commit below, ab8500_bm_of_remove() needs to be called after a
successful ab8500_bm_of_probe() call.
This commit has only updated the remove function.

Fix the error handling path of the probe the same way.

Fixes: 6252c706cdb0 ("power: supply: ab8500: Standardize operating temperature")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
For a better understanding, maybe, the ab8500_bm_of_remove() call in the
remove function should be moved at the bottom of the function, so that
resources are freed in reverse order than allocation.
I've not looked in details if the position of this call was important or
not, though.
---
 drivers/power/supply/ab8500_charger.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Linus Walleij Jan. 2, 2022, 6:43 a.m. UTC | #1
On Tue, Dec 28, 2021 at 9:43 PM Christophe JAILLET
<christophe.jaillet@wanadoo.fr> wrote:

> Since the commit below, ab8500_bm_of_remove() needs to be called after a
> successful ab8500_bm_of_probe() call.
> This commit has only updated the remove function.
>
> Fix the error handling path of the probe the same way.
>
> Fixes: 6252c706cdb0 ("power: supply: ab8500: Standardize operating temperature")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Nice catch,
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij
Sebastian Reichel Jan. 3, 2022, 5:40 p.m. UTC | #2
Hi,

On Sun, Jan 02, 2022 at 07:43:55AM +0100, Linus Walleij wrote:
> On Tue, Dec 28, 2021 at 9:43 PM Christophe JAILLET
> <christophe.jaillet@wanadoo.fr> wrote:
> 
> > Since the commit below, ab8500_bm_of_remove() needs to be called after a
> > successful ab8500_bm_of_probe() call.
> > This commit has only updated the remove function.
> >
> > Fix the error handling path of the probe the same way.
> >
> > Fixes: 6252c706cdb0 ("power: supply: ab8500: Standardize operating temperature")
> > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> 
> Nice catch,
> Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Thanks, queued.

-- Sebastian
diff mbox series

Patch

diff --git a/drivers/power/supply/ab8500_charger.c b/drivers/power/supply/ab8500_charger.c
index db7457064a17..ce074c018dcb 100644
--- a/drivers/power/supply/ab8500_charger.c
+++ b/drivers/power/supply/ab8500_charger.c
@@ -3665,11 +3665,13 @@  static int ab8500_charger_probe(struct platform_device *pdev)
 	}
 	if (!match) {
 		dev_err(dev, "no matching components\n");
-		return -ENODEV;
+		ret = -ENODEV;
+		goto remove_ab8500_bm;
 	}
 	if (IS_ERR(match)) {
 		dev_err(dev, "could not create component match\n");
-		return PTR_ERR(match);
+		ret = PTR_ERR(match);
+		goto remove_ab8500_bm;
 	}
 
 	/* Notifier for external charger enabling */
@@ -3710,6 +3712,8 @@  static int ab8500_charger_probe(struct platform_device *pdev)
 	if (!di->ac_chg.enabled)
 		blocking_notifier_chain_unregister(
 			&charger_notifier_list, &charger_nb);
+remove_ab8500_bm:
+	ab8500_bm_of_remove(di->usb_chg.psy, di->bm);
 	return ret;
 }