All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Markus Elfring" <Markus.Elfring@web.de>, linux-usb@vger.kernel.org
Subject: Re: [PATCH] usb: bdc: Use devm_clk_get_optional_enabled() in bdc_probe()
Date: Thu, 19 Nov 2026 19:12:14 +0000	[thread overview]
Message-ID: <sashiko-outbox-223836@kernel.org> (raw)
In-Reply-To: <07112f96-430c-4109-9aca-e5d17e333d67@web.de>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] usb: bdc: double clk_disable_unprepare() in bdc_probe() and
  bdc_remove()
--

commit c38d4d54fe3bb2b28c05aba44e9d088e2b2d7d63
Author: Markus Elfring <elfring@users.sourceforge.net>

usb: bdc: Use devm_clk_get_optional_enabled() in bdc_probe()

This commit replaces devm_clk_get_optional() and clk_prepare_enable() in
bdc_probe() with devm_clk_get_optional_enabled().

> diff --git a/drivers/usb/gadget/udc/bdc/bdc_core.c b/drivers/usb/gadget/udc/bdc/bdc_core.c
> index 5149c98bf9bf9..ce09327250f43 100644
> --- a/drivers/usb/gadget/udc/bdc/bdc_core.c
> +++ b/drivers/usb/gadget/udc/bdc/bdc_core.c
> @@ -530,16 +530,10 @@ static int bdc_probe(struct platform_device *pdev)
>  		}
>  	}
>  
> -	bdc->clk = devm_clk_get_optional(dev, "sw_usbd");
> +	bdc->clk = devm_clk_get_optional_enabled(dev, "sw_usbd");
>  	if (IS_ERR(bdc->clk))
>  		return PTR_ERR(bdc->clk);
>  
> -	ret = clk_prepare_enable(bdc->clk);
> -	if (ret) {
> -		dev_err(dev, "could not enable clock\n");
> -		return ret;
> -	}
> -
>  	ret = bdc_phy_init(bdc);
>  	if (ret) {
>  		dev_err(bdc->dev, "BDC phy init failure:%d\n", ret);

[Severity: High]
Does this cause clk_disable_unprepare(bdc->clk) to be called twice on probe
failure or driver removal?

devm_clk_get_optional_enabled() registers a devres action that calls
clk_disable_unprepare(bdc->clk) on probe failure or device unbind, but the
manual clk_disable_unprepare(bdc->clk) calls remain in the disable_clk
error path of bdc_probe() and in bdc_remove().  That underflows the clock
enable and prepare counts, triggering WARN_ON() in clk_core_disable() and
clk_core_unprepare().

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/07112f96-430c-4109-9aca-e5d17e333d67@web.de?part=1

  reply	other threads:[~2026-11-19 19:12 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19 19:06 [PATCH] usb: bdc: Use devm_clk_get_optional_enabled() in bdc_probe() Markus Elfring
2026-11-19 19:12 ` sashiko-bot [this message]
2026-11-19 20:19 ` Christophe JAILLET
2026-11-20  4:34   ` Greg Kroah-Hartman
2026-11-20  7:15     ` Markus Elfring
2026-11-20  7:06   ` Markus Elfring

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=sashiko-outbox-223836@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Markus.Elfring@web.de \
    --cc=linux-usb@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.