From: Patrice CHOTARD <patrice.chotard@foss.st.com>
To: Jiale Yao <yaojiale02@163.com>, Mark Brown <broonie@kernel.org>,
"Maxime Coquelin" <mcoquelin.stm32@gmail.com>,
Alexandre Torgue <alexandre.torgue@foss.st.com>,
Felix Gu <ustc.gu@gmail.com>, <linux-spi@vger.kernel.org>,
<linux-stm32@st-md-mailman.stormreply.com>,
<linux-arm-kernel@lists.infradead.org>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/2] spi: stm32-ospi: handle runtime resume failure in remove
Date: Fri, 30 Oct 2026 15:47:44 +0100 [thread overview]
Message-ID: <aebeb751-59f7-4281-983b-a7580196556f@foss.st.com> (raw)
In-Reply-To: <20261019084443.1824122-2-yaojiale02@163.com>
On 10/19/26 10:44, Jiale Yao wrote:
> stm32_ospi_remove() continues with the controller teardown when runtime
> resume fails. The register write can then access an unavailable device,
> and the final runtime PM put does not match an acquired reference.
>
> Keep the resource cleanup, but skip the register access and matching
> runtime PM put when the resume operation fails.
>
> Fixes: 73cd1f97946a ("spi: stm32-ospi: Fix resource leak in remove() callback")
> Signed-off-by: Jiale Yao <yaojiale02@163.com>
> ---
> drivers/spi/spi-stm32-ospi.c | 12 ++++++++----
> 1 file changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/spi/spi-stm32-ospi.c b/drivers/spi/spi-stm32-ospi.c
> index fa0e8e83cb1b..1340e62ebe1b 100644
> --- a/drivers/spi/spi-stm32-ospi.c
> +++ b/drivers/spi/spi-stm32-ospi.c
> @@ -986,12 +986,15 @@ static int stm32_ospi_probe(struct platform_device *pdev)
> static void stm32_ospi_remove(struct platform_device *pdev)
> {
> struct stm32_ospi *ospi = platform_get_drvdata(pdev);
> + int ret;
>
> - pm_runtime_resume_and_get(ospi->dev);
> + ret = pm_runtime_resume_and_get(ospi->dev);
>
> spi_unregister_controller(ospi->ctrl);
> - /* Disable ospi */
> - writel_relaxed(0, ospi->regs_base + OSPI_CR);
> + if (ret >= 0) {
> + /* Disable ospi */
> + writel_relaxed(0, ospi->regs_base + OSPI_CR);
> + }
> mutex_destroy(&ospi->lock);
>
> if (ospi->dma_chtx)
> @@ -1001,7 +1004,8 @@ static void stm32_ospi_remove(struct platform_device *pdev)
>
> reset_control_release(ospi->rstc);
>
> - pm_runtime_put_sync_suspend(ospi->dev);
> + if (ret >= 0)
> + pm_runtime_put_sync_suspend(ospi->dev);
> pm_runtime_force_suspend(ospi->dev);
> }
>
Hi Jiale
Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
Thanks
Patrice
next prev parent reply other threads:[~2026-10-30 14:48 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-19 8:44 [PATCH 0/2] spi: handle runtime resume failures Jiale Yao
2026-10-19 8:44 ` [PATCH 1/2] spi: stm32-ospi: handle runtime resume failure in remove Jiale Yao
2026-10-30 14:47 ` Patrice CHOTARD [this message]
2026-10-19 8:44 ` [PATCH 2/2] spi: ti-qspi: handle setup clock runtime resume failure Jiale Yao
2026-10-19 23:57 ` Atsushi Nemoto
2026-11-02 22:39 ` [PATCH 0/2] spi: handle runtime resume failures Mark Brown
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=aebeb751-59f7-4281-983b-a7580196556f@foss.st.com \
--to=patrice.chotard@foss.st.com \
--cc=alexandre.torgue@foss.st.com \
--cc=broonie@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=ustc.gu@gmail.com \
--cc=yaojiale02@163.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®