mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Peter Chen (Qualcomm)" <peter.chen@kernel.org>
To: Xu Yang <xu.yang_2@oss.nxp.com>
Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org,
	linux-kernel@vger.kernel.org, imx@lists.linux.dev,
	jun.li@nxp.com
Subject: Re: [PATCH] usb: chipidea: otg: avoid workqueue resource leak if otg fsm init fail
Date: Tue, 3 Nov 2026 17:13:17 -0800	[thread overview]
Message-ID: <auqGrXyD9Dn4kaML@hu-petche-lv.qualcomm.com> (raw)
In-Reply-To: <20261030072130.276679-1-xu.yang_2@oss.nxp.com>

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

      reply	other threads:[~2026-11-04  1:13 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-30  7:21 Xu Yang
2026-11-04  1:13 ` Peter Chen (Qualcomm) [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=auqGrXyD9Dn4kaML@hu-petche-lv.qualcomm.com \
    --to=peter.chen@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=imx@lists.linux.dev \
    --cc=jun.li@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=xu.yang_2@oss.nxp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®