Linux USB
 help / color / mirror / Atom feed
* [PATCH] usb: typec: ucsi: destroy work queue on fwnode_usb_role_switch_get() fails
@ 2026-06-24  8:13 Haoxiang Li
  2026-06-24 10:56 ` Heikki Krogerus
  0 siblings, 1 reply; 2+ messages in thread
From: Haoxiang Li @ 2026-06-24  8:13 UTC (permalink / raw)
  To: heikki.krogerus, gregkh, bleung, abelvesa, jthies,
	myrrhperiwinkle, pooja.katiyar, venkat.jayaraman, yuanhsinte,
	johan, quic_linyyuan
  Cc: linux-usb, linux-kernel, Haoxiang Li, stable

Call destroy_workqueue() if fwnode_usb_role_switch_get() fails
to destroy the work queue con->wq.

Fixes: 3c162511530c ("usb: typec: ucsi: Wait for the USB role switches")
Cc: stable@vger.kernel.org
Signed-off-by: Haoxiang Li <haoxiang_li2024@163.com>
---
 drivers/usb/typec/ucsi/ucsi.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c
index 61cb24ed820f..63303e26929f 100644
--- a/drivers/usb/typec/ucsi/ucsi.c
+++ b/drivers/usb/typec/ucsi/ucsi.c
@@ -1663,9 +1663,11 @@ static int ucsi_register_port(struct ucsi *ucsi, struct ucsi_connector *con)
 
 	cap->fwnode = ucsi_find_fwnode(con);
 	con->usb_role_sw = fwnode_usb_role_switch_get(cap->fwnode);
-	if (IS_ERR(con->usb_role_sw))
+	if (IS_ERR(con->usb_role_sw)) {
+		destroy_workqueue(con->wq);
 		return dev_err_probe(ucsi->dev, PTR_ERR(con->usb_role_sw),
 			"con%d: failed to get usb role switch\n", con->num);
+	}
 
 	/* Delay other interactions with the con until registration is complete */
 	mutex_lock(&con->lock);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] usb: typec: ucsi: destroy work queue on fwnode_usb_role_switch_get() fails
  2026-06-24  8:13 [PATCH] usb: typec: ucsi: destroy work queue on fwnode_usb_role_switch_get() fails Haoxiang Li
@ 2026-06-24 10:56 ` Heikki Krogerus
  0 siblings, 0 replies; 2+ messages in thread
From: Heikki Krogerus @ 2026-06-24 10:56 UTC (permalink / raw)
  To: Haoxiang Li
  Cc: gregkh, bleung, abelvesa, jthies, myrrhperiwinkle, pooja.katiyar,
	venkat.jayaraman, yuanhsinte, johan, quic_linyyuan, linux-usb,
	linux-kernel, stable

On Wed, Jun 24, 2026 at 04:13:01PM +0800, Haoxiang Li wrote:
> Call destroy_workqueue() if fwnode_usb_role_switch_get() fails
> to destroy the work queue con->wq.
> 
> Fixes: 3c162511530c ("usb: typec: ucsi: Wait for the USB role switches")
> Cc: stable@vger.kernel.org
> Signed-off-by: Haoxiang Li <haoxiang_li2024@163.com>
> ---
>  drivers/usb/typec/ucsi/ucsi.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c
> index 61cb24ed820f..63303e26929f 100644
> --- a/drivers/usb/typec/ucsi/ucsi.c
> +++ b/drivers/usb/typec/ucsi/ucsi.c
> @@ -1663,9 +1663,11 @@ static int ucsi_register_port(struct ucsi *ucsi, struct ucsi_connector *con)
>  
>  	cap->fwnode = ucsi_find_fwnode(con);
>  	con->usb_role_sw = fwnode_usb_role_switch_get(cap->fwnode);
> -	if (IS_ERR(con->usb_role_sw))
> +	if (IS_ERR(con->usb_role_sw)) {
> +		destroy_workqueue(con->wq);
>  		return dev_err_probe(ucsi->dev, PTR_ERR(con->usb_role_sw),
>  			"con%d: failed to get usb role switch\n", con->num);
> +	}

You need to add a label err_destroy_workqueue after the
mutex_unlock(&con->lock) and then here:

	if (IS_ERR(con->usb_role_sw)) {
		ret = PTR_ERR(con->usb_role_sw);
		dev_err(ucsi->dev, "con%d: failed to get usb role switch\n", con->num);
                goto err_destroy_workqueue;
	}

thanks,

-- 
heikki

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-06-24 10:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-24  8:13 [PATCH] usb: typec: ucsi: destroy work queue on fwnode_usb_role_switch_get() fails Haoxiang Li
2026-06-24 10:56 ` Heikki Krogerus

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox