diff mbox series

[2/4] usb: typec: tipd: Fix spurious fwnode_handle_put in error path

Message ID 20221114174449.34634-2-sven@svenpeter.dev
State New
Headers show
Series [1/4] usb: typec: tipd: Cleanup resources if devm_tps6598_psy_register fails | expand

Commit Message

Sven Peter Nov. 14, 2022, 5:44 p.m. UTC
The err_role_put error path always calls fwnode_handle_put to release
the fwnode. This path can be reached after probe itself has already
released that fwnode though. Fix that by moving fwnode_handle_put in the
happy path to the very end.

Fixes: 18a6c866bb19 ("usb: typec: tps6598x: Add USB role switching logic")
Signed-off-by: Sven Peter <sven@svenpeter.dev>
---
 drivers/usb/typec/tipd/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Heikki Krogerus Nov. 16, 2022, 12:16 p.m. UTC | #1
On Mon, Nov 14, 2022 at 06:44:47PM +0100, Sven Peter wrote:
> The err_role_put error path always calls fwnode_handle_put to release
> the fwnode. This path can be reached after probe itself has already
> released that fwnode though. Fix that by moving fwnode_handle_put in the
> happy path to the very end.
> 
> Fixes: 18a6c866bb19 ("usb: typec: tps6598x: Add USB role switching logic")
> Signed-off-by: Sven Peter <sven@svenpeter.dev>

This looks like stable material as well.

Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

> ---
>  drivers/usb/typec/tipd/core.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c
> index ebc786d728e2..824e573af570 100644
> --- a/drivers/usb/typec/tipd/core.c
> +++ b/drivers/usb/typec/tipd/core.c
> @@ -834,7 +834,6 @@ static int tps6598x_probe(struct i2c_client *client)
>  		ret = PTR_ERR(tps->port);
>  		goto err_role_put;
>  	}
> -	fwnode_handle_put(fwnode);
>  
>  	if (tps->status & TPS_STATUS_PLUG_PRESENT) {
>  		ret = tps6598x_read16(tps, TPS_REG_POWER_STATUS, &tps->pwr_status);
> @@ -858,6 +857,7 @@ static int tps6598x_probe(struct i2c_client *client)
>  	}
>  
>  	i2c_set_clientdata(client, tps);
> +	fwnode_handle_put(fwnode);
>  
>  	return 0;
>  

thanks,
diff mbox series

Patch

diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c
index ebc786d728e2..824e573af570 100644
--- a/drivers/usb/typec/tipd/core.c
+++ b/drivers/usb/typec/tipd/core.c
@@ -834,7 +834,6 @@  static int tps6598x_probe(struct i2c_client *client)
 		ret = PTR_ERR(tps->port);
 		goto err_role_put;
 	}
-	fwnode_handle_put(fwnode);
 
 	if (tps->status & TPS_STATUS_PLUG_PRESENT) {
 		ret = tps6598x_read16(tps, TPS_REG_POWER_STATUS, &tps->pwr_status);
@@ -858,6 +857,7 @@  static int tps6598x_probe(struct i2c_client *client)
 	}
 
 	i2c_set_clientdata(client, tps);
+	fwnode_handle_put(fwnode);
 
 	return 0;