diff mbox series

phy: ti: tusb1210: Fix an error handling path in tusb1210_probe()

Message ID 07c4926c42243cedb3b6067a241bb486fdda01b5.1648991162.git.christophe.jaillet@wanadoo.fr
State Accepted
Commit a9f17d0c0778dd971dc9770fa0a2085a41d8c5e4
Headers show
Series phy: ti: tusb1210: Fix an error handling path in tusb1210_probe() | expand

Commit Message

Christophe JAILLET April 3, 2022, 1:06 p.m. UTC
tusb1210_probe_charger_detect() must be undone by a corresponding
tusb1210_remove_charger_detect() in the error handling path, as already
done in the remove function.

Fixes: 48969a5623ed ("phy: ti: tusb1210: Add charger detection")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/phy/ti/phy-tusb1210.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

Comments

Hans de Goede April 4, 2022, 9:15 a.m. UTC | #1
Hi,

On 4/3/22 15:06, Christophe JAILLET wrote:
> tusb1210_probe_charger_detect() must be undone by a corresponding
> tusb1210_remove_charger_detect() in the error handling path, as already
> done in the remove function.
> 
> Fixes: 48969a5623ed ("phy: ti: tusb1210: Add charger detection")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Thanks, patch looks good to me:

Reviewed-by: Hans de Goede <hdegoede@redhat.com>

Regards,

Hans


> ---
>  drivers/phy/ti/phy-tusb1210.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/phy/ti/phy-tusb1210.c b/drivers/phy/ti/phy-tusb1210.c
> index a0cdbcadf09e..008d80977fc5 100644
> --- a/drivers/phy/ti/phy-tusb1210.c
> +++ b/drivers/phy/ti/phy-tusb1210.c
> @@ -537,12 +537,18 @@ static int tusb1210_probe(struct ulpi *ulpi)
>  	tusb1210_probe_charger_detect(tusb);
>  
>  	tusb->phy = ulpi_phy_create(ulpi, &phy_ops);
> -	if (IS_ERR(tusb->phy))
> -		return PTR_ERR(tusb->phy);
> +	if (IS_ERR(tusb->phy)) {
> +		ret = PTR_ERR(tusb->phy);
> +		goto err_remove_charger;
> +	}
>  
>  	phy_set_drvdata(tusb->phy, tusb);
>  	ulpi_set_drvdata(ulpi, tusb);
>  	return 0;
> +
> +err_remove_charger:
> +	tusb1210_remove_charger_detect(tusb);
> +	return ret;
>  }
>  
>  static void tusb1210_remove(struct ulpi *ulpi)
Vinod Koul April 11, 2022, 5:37 p.m. UTC | #2
On 03-04-22, 15:06, Christophe JAILLET wrote:
> tusb1210_probe_charger_detect() must be undone by a corresponding
> tusb1210_remove_charger_detect() in the error handling path, as already
> done in the remove function.

Applied, thanks
diff mbox series

Patch

diff --git a/drivers/phy/ti/phy-tusb1210.c b/drivers/phy/ti/phy-tusb1210.c
index a0cdbcadf09e..008d80977fc5 100644
--- a/drivers/phy/ti/phy-tusb1210.c
+++ b/drivers/phy/ti/phy-tusb1210.c
@@ -537,12 +537,18 @@  static int tusb1210_probe(struct ulpi *ulpi)
 	tusb1210_probe_charger_detect(tusb);
 
 	tusb->phy = ulpi_phy_create(ulpi, &phy_ops);
-	if (IS_ERR(tusb->phy))
-		return PTR_ERR(tusb->phy);
+	if (IS_ERR(tusb->phy)) {
+		ret = PTR_ERR(tusb->phy);
+		goto err_remove_charger;
+	}
 
 	phy_set_drvdata(tusb->phy, tusb);
 	ulpi_set_drvdata(ulpi, tusb);
 	return 0;
+
+err_remove_charger:
+	tusb1210_remove_charger_detect(tusb);
+	return ret;
 }
 
 static void tusb1210_remove(struct ulpi *ulpi)