* [PATCH] usb: chipidea: otg: avoid workqueue resource leak if otg fsm init fail
@ 2026-10-30 7:21 Xu Yang
2026-11-04 1:13 ` Peter Chen (Qualcomm)
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 [flat|nested] 2+ messages in thread
* Re: [PATCH] usb: chipidea: otg: avoid workqueue resource leak if otg fsm init fail
2026-10-30 7:21 [PATCH] usb: chipidea: otg: avoid workqueue resource leak if otg fsm init fail Xu Yang
@ 2026-11-04 1:13 ` Peter Chen (Qualcomm)
0 siblings, 0 replies; 2+ messages in thread
From: Peter Chen (Qualcomm) @ 2026-11-04 1:13 UTC (permalink / raw)
To: Xu Yang; +Cc: gregkh, linux-usb, linux-kernel, imx, jun.li
On 26-10-30 15:21:30, Xu Yang wrote:
> 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>
Acked-by: Peter Chen <peter.chen@kernel.org>
Peter
> ---
> 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
>
--
Thanks,
Peter Chen
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-04 1:13 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-11-04 1:13 ` Peter Chen (Qualcomm)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®