diff mbox series

power: supply: lp8788: Fix an error handling path in 'lp8788_charger_probe()'

Message ID 20200508071150.204974-1-christophe.jaillet@wanadoo.fr
State Not Applicable, archived
Headers show
Series power: supply: lp8788: Fix an error handling path in 'lp8788_charger_probe()' | expand

Commit Message

Christophe JAILLET May 8, 2020, 7:11 a.m. UTC
In case of error, resources allocated in 'lp8788_setup_adc_channel()' must
be released.

Add a call to 'lp8788_release_adc_channel()' as already done in the remove
function.

Fixes: 98a276649358 ("power_supply: Add new lp8788 charger driver")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/power/supply/lp8788-charger.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Sebastian Reichel May 9, 2020, 12:14 a.m. UTC | #1
Hi,

Please change the driver to call devm_iio_channel_get() instead of
iio_channel_get() and drop the lp8788_release_adc_channel() function.

-- Sebastian

On Fri, May 08, 2020 at 09:11:50AM +0200, Christophe JAILLET wrote:
> In case of error, resources allocated in 'lp8788_setup_adc_channel()' must
> be released.
> 
> Add a call to 'lp8788_release_adc_channel()' as already done in the remove
> function.
> 
> Fixes: 98a276649358 ("power_supply: Add new lp8788 charger driver")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
>  drivers/power/supply/lp8788-charger.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/power/supply/lp8788-charger.c b/drivers/power/supply/lp8788-charger.c
> index 84a206f42a8e..641815eb24bc 100644
> --- a/drivers/power/supply/lp8788-charger.c
> +++ b/drivers/power/supply/lp8788-charger.c
> @@ -719,13 +719,17 @@ static int lp8788_charger_probe(struct platform_device *pdev)
>  
>  	ret = lp8788_psy_register(pdev, pchg);
>  	if (ret)
> -		return ret;
> +		goto err_release_adc_channel;
>  
>  	ret = lp8788_irq_register(pdev, pchg);
>  	if (ret)
>  		dev_warn(dev, "failed to register charger irq: %d\n", ret);
>  
>  	return 0;
> +
> +err_release_adc_channel:
> +	lp8788_release_adc_channel(pchg);
> +	return ret;
>  }
>  
>  static int lp8788_charger_remove(struct platform_device *pdev)
> -- 
> 2.25.1
>
diff mbox series

Patch

diff --git a/drivers/power/supply/lp8788-charger.c b/drivers/power/supply/lp8788-charger.c
index 84a206f42a8e..641815eb24bc 100644
--- a/drivers/power/supply/lp8788-charger.c
+++ b/drivers/power/supply/lp8788-charger.c
@@ -719,13 +719,17 @@  static int lp8788_charger_probe(struct platform_device *pdev)
 
 	ret = lp8788_psy_register(pdev, pchg);
 	if (ret)
-		return ret;
+		goto err_release_adc_channel;
 
 	ret = lp8788_irq_register(pdev, pchg);
 	if (ret)
 		dev_warn(dev, "failed to register charger irq: %d\n", ret);
 
 	return 0;
+
+err_release_adc_channel:
+	lp8788_release_adc_channel(pchg);
+	return ret;
 }
 
 static int lp8788_charger_remove(struct platform_device *pdev)