* [PATCH] usb: chipidea: otg: avoid workqueue resource leak if otg fsm init fail
@ 2026-10-30 7:21 Xu Yang
2026-10-30 7:20 ` sashiko-bot
0 siblings, 1 reply; 2+ messages in thread
From: Xu Yang @ 2026-10-30 7:21 UTC (permalink / raw)
To: peter.chen, gregkh; +Cc: linux-usb, linux-kernel, imx, jun.li
From: Xu Yang <xu.yang_2@nxp.com>
If ci_hdrc_otg_fsm_init() fail, error propagates to ci_hdrc_probe(), which
jumps to the deinit_gadget label, bypassing the deinit_otg label where the
ci_otg_wq workqueue would normally be destroyed. Finally it cause resource
leak on previous created workqueue.
Fixes: 57677be5ef83 ("usb: chipidea: usb OTG fsm initialization.")
Cc: stable@vger.kernel.org
Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
---
drivers/usb/chipidea/otg.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/chipidea/otg.c b/drivers/usb/chipidea/otg.c
index 5eb3b32c2e87..89a6a37815f0 100644
--- a/drivers/usb/chipidea/otg.c
+++ b/drivers/usb/chipidea/otg.c
@@ -246,6 +246,8 @@ static void ci_otg_work(struct work_struct *work)
*/
int ci_hdrc_otg_init(struct ci_hdrc *ci)
{
+ int ret;
+
INIT_WORK(&ci->work, ci_otg_work);
ci->wq = create_freezable_workqueue("ci_otg");
if (!ci->wq) {
@@ -253,8 +255,13 @@ int ci_hdrc_otg_init(struct ci_hdrc *ci)
return -ENODEV;
}
- if (ci_otg_is_fsm_mode(ci))
- return ci_hdrc_otg_fsm_init(ci);
+ if (ci_otg_is_fsm_mode(ci)) {
+ ret = ci_hdrc_otg_fsm_init(ci);
+ if (ret < 0) {
+ destroy_workqueue(ci->wq);
+ return ret;
+ }
+ }
return 0;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-10-30 7:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-30 7:21 [PATCH] usb: chipidea: otg: avoid workqueue resource leak if otg fsm init fail Xu Yang
2026-10-30 7:20 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox