* [PATCH] usb: typec: fusb302: Fix resource leak when devm_drm_dp_hpd_bridge_add() fails
@ 2026-04-21 11:24 Felix Gu
2026-04-27 9:20 ` Heikki Krogerus
0 siblings, 1 reply; 2+ messages in thread
From: Felix Gu @ 2026-04-21 11:24 UTC (permalink / raw)
To: Heikki Krogerus, Greg Kroah-Hartman, Sebastian Reichel
Cc: linux-usb, linux-kernel, Felix Gu
If devm_drm_dp_hpd_bridge_add() fails during fusb302_probe(), the original
code returned directly without cleaning up the resources.
Route the failure through the existing unwind path so probe cleans up the
same resources that are released in remove().
Fixes: 5d79c525405d ("usb: typec: fusb302: add DRM DP HPD bridge support")
Signed-off-by: Felix Gu <ustc.gu@gmail.com>
---
drivers/usb/typec/tcpm/fusb302.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/typec/tcpm/fusb302.c b/drivers/usb/typec/tcpm/fusb302.c
index 889c4c29c1b8..5b631422c128 100644
--- a/drivers/usb/typec/tcpm/fusb302.c
+++ b/drivers/usb/typec/tcpm/fusb302.c
@@ -1776,10 +1776,15 @@ static int fusb302_probe(struct i2c_client *client)
ret = devm_drm_dp_hpd_bridge_add(chip->dev, bridge_dev);
if (ret)
- return ret;
+ goto free_irq;
- return ret;
+ return 0;
+free_irq:
+ disable_irq_wake(chip->gpio_int_n_irq);
+ free_irq(chip->gpio_int_n_irq, chip);
+ cancel_work_sync(&chip->irq_work);
+ cancel_delayed_work_sync(&chip->bc_lvl_handler);
tcpm_unregister_port:
tcpm_unregister_port(chip->tcpm_port);
fwnode_handle_put(chip->tcpc_dev.fwnode);
---
base-commit: 97e797263a5e963da3d1e66e743fd518567dfe37
change-id: 20260421-fusb-0e7085ce431a
Best regards,
--
Felix Gu <ustc.gu@gmail.com>
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] usb: typec: fusb302: Fix resource leak when devm_drm_dp_hpd_bridge_add() fails
2026-04-21 11:24 [PATCH] usb: typec: fusb302: Fix resource leak when devm_drm_dp_hpd_bridge_add() fails Felix Gu
@ 2026-04-27 9:20 ` Heikki Krogerus
0 siblings, 0 replies; 2+ messages in thread
From: Heikki Krogerus @ 2026-04-27 9:20 UTC (permalink / raw)
To: Felix Gu; +Cc: Greg Kroah-Hartman, Sebastian Reichel, linux-usb, linux-kernel
On Tue, Apr 21, 2026 at 07:24:56PM +0800, Felix Gu wrote:
> If devm_drm_dp_hpd_bridge_add() fails during fusb302_probe(), the original
> code returned directly without cleaning up the resources.
>
> Route the failure through the existing unwind path so probe cleans up the
> same resources that are released in remove().
>
> Fixes: 5d79c525405d ("usb: typec: fusb302: add DRM DP HPD bridge support")
> Signed-off-by: Felix Gu <ustc.gu@gmail.com>
> ---
> drivers/usb/typec/tcpm/fusb302.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/usb/typec/tcpm/fusb302.c b/drivers/usb/typec/tcpm/fusb302.c
> index 889c4c29c1b8..5b631422c128 100644
> --- a/drivers/usb/typec/tcpm/fusb302.c
> +++ b/drivers/usb/typec/tcpm/fusb302.c
> @@ -1776,10 +1776,15 @@ static int fusb302_probe(struct i2c_client *client)
>
> ret = devm_drm_dp_hpd_bridge_add(chip->dev, bridge_dev);
> if (ret)
> - return ret;
> + goto free_irq;
Couldn't you just call that before requesting the irq?
thanks,
> - return ret;
> + return 0;
>
> +free_irq:
> + disable_irq_wake(chip->gpio_int_n_irq);
> + free_irq(chip->gpio_int_n_irq, chip);
> + cancel_work_sync(&chip->irq_work);
> + cancel_delayed_work_sync(&chip->bc_lvl_handler);
> tcpm_unregister_port:
> tcpm_unregister_port(chip->tcpm_port);
> fwnode_handle_put(chip->tcpc_dev.fwnode);
>
> ---
> base-commit: 97e797263a5e963da3d1e66e743fd518567dfe37
> change-id: 20260421-fusb-0e7085ce431a
>
> Best regards,
> --
> Felix Gu <ustc.gu@gmail.com>
--
heikki
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-04-27 9:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-21 11:24 [PATCH] usb: typec: fusb302: Fix resource leak when devm_drm_dp_hpd_bridge_add() fails Felix Gu
2026-04-27 9:20 ` Heikki Krogerus
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox