From: Antonio Borneo <antonio.borneo@foss.st.com>
To: Haotian Zhang <vulab@iscas.ac.cn>, <linus.walleij@linaro.org>
Cc: <mcoquelin.stm32@gmail.com>, <alexandre.torgue@foss.st.com>,
<linux-gpio@vger.kernel.org>,
<linux-stm32@st-md-mailman.stormreply.com>,
<linux-arm-kernel@lists.infradead.org>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] pinctrl: stm32: fix hwspinlock resource leak in probe function
Date: Wed, 29 Oct 2025 10:30:44 +0100 [thread overview]
Message-ID: <1ecb3859ae79fee2031e8aae5380f509629eae93.camel@foss.st.com> (raw)
In-Reply-To: <20251029014252.178-1-vulab@iscas.ac.cn>
On Wed, 2025-10-29 at 09:42 +0800, Haotian Zhang wrote:
> In stm32_pctl_probe(), hwspin_lock_request_specific() is called to
> request a hwspinlock, but the acquired lock is not freed on multiple
> error paths after this call. This causes resource leakage when the
> function fails to initialize properly.
>
> Use devm_hwspin_lock_request_specific() instead of
> hwspin_lock_request_specific() to automatically manage the hwspinlock
> resource lifecycle.
>
> Fixes: 97cfb6cd34f2 ("pinctrl: stm32: protect configuration registers with a hwspinlock")
> Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn>
> ---
> drivers/pinctrl/stm32/pinctrl-stm32.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/pinctrl/stm32/pinctrl-stm32.c b/drivers/pinctrl/stm32/pinctrl-stm32.c
> index 823c8fe758e2..d9a2d20a7e6b 100644
> --- a/drivers/pinctrl/stm32/pinctrl-stm32.c
> +++ b/drivers/pinctrl/stm32/pinctrl-stm32.c
> @@ -1671,7 +1671,7 @@ int stm32_pctl_probe(struct platform_device *pdev)
> if (hwlock_id == -EPROBE_DEFER)
> return hwlock_id;
> } else {
> - pctl->hwlock = hwspin_lock_request_specific(hwlock_id);
> + pctl->hwlock = devm_hwspin_lock_request_specific(dev, hwlock_id);
> }
>
> spin_lock_init(&pctl->irqmux_lock);
Reviewed-by: Antonio Borneo <antonio.borneo@foss.st.com>
Thanks!
Antonio
next prev parent reply other threads:[~2025-10-29 9:31 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-29 1:42 [PATCH] pinctrl: stm32: fix hwspinlock resource leak in probe function Haotian Zhang
2025-10-29 9:30 ` Antonio Borneo [this message]
2025-10-29 22:38 ` Linus Walleij
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=1ecb3859ae79fee2031e8aae5380f509629eae93.camel@foss.st.com \
--to=antonio.borneo@foss.st.com \
--cc=alexandre.torgue@foss.st.com \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=vulab@iscas.ac.cn \
/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;
as well as URLs for NNTP newsgroup(s).