[PATCH] usb: typec: ucsi: destroy work queue on fwnode_usb_role_switch_get() fails

From: Haoxiang Li

Date: Wed Jun 24 2026 - 04:15:27 EST


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@xxxxxxxxxxxxxxx
Signed-off-by: Haoxiang Li <haoxiang_li2024@xxxxxxx>
---
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