From: Patrice CHOTARD <patrice.chotard@st.com>
To: Zhang Qilong <zhangqilong3@huawei.com>,
"broonie@kernel.org" <broonie@kernel.org>,
"mcoquelin.stm32@gmail.com" <mcoquelin.stm32@gmail.com>,
Alexandre TORGUE <alexandre.torgue@st.com>
Cc: "linux-stm32@st-md-mailman.stormreply.com"
<linux-stm32@st-md-mailman.stormreply.com>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"linux-spi@vger.kernel.org" <linux-spi@vger.kernel.org>
Subject: Re: [Linux-stm32] [PATCH] spi: stm32-qspi: fix reference leak in stm32 qspi operations
Date: Fri, 6 Nov 2020 12:38:16 +0000 [thread overview]
Message-ID: <76ebfa03-59d0-ed49-fa9b-87d9dd9f21f7@st.com> (raw)
In-Reply-To: <20201106015357.141235-1-zhangqilong3@huawei.com>
Hi Zhang
On 11/6/20 2:53 AM, Zhang Qilong wrote:
> pm_runtime_get_sync will increment pm usage counter even it
> failed. Forgetting to pm_runtime_put_noidle will result in
> reference leak in two callers(stm32_qspi_exec_op and
> stm32_qspi_setup), so we should fix it.
>
> Fixes: 9d282c17b023a ("spi: stm32-qspi: Add pm_runtime support")
> Signed-off-by: Zhang Qilong <zhangqilong3@huawei.com>
> ---
> drivers/spi/spi-stm32-qspi.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/spi/spi-stm32-qspi.c b/drivers/spi/spi-stm32-qspi.c
> index a900962b4336..947e6b9dc9f4 100644
> --- a/drivers/spi/spi-stm32-qspi.c
> +++ b/drivers/spi/spi-stm32-qspi.c
> @@ -434,8 +434,10 @@ static int stm32_qspi_exec_op(struct spi_mem *mem, const struct spi_mem_op *op)
> int ret;
>
> ret = pm_runtime_get_sync(qspi->dev);
> - if (ret < 0)
> + if (ret < 0) {
> + pm_runtime_put_noidle(qspi->dev);
> return ret;
> + }
>
> mutex_lock(&qspi->lock);
> ret = stm32_qspi_send(mem, op);
> @@ -462,8 +464,10 @@ static int stm32_qspi_setup(struct spi_device *spi)
> return -EINVAL;
>
> ret = pm_runtime_get_sync(qspi->dev);
> - if (ret < 0)
> + if (ret < 0) {
> + pm_runtime_put_noidle(qspi->dev);
> return ret;
> + }
>
> presc = DIV_ROUND_UP(qspi->clk_rate, spi->max_speed_hz) - 1;
>
Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
Thanks
next prev parent reply other threads:[~2020-11-06 12:38 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-06 1:53 [PATCH] spi: stm32-qspi: fix reference leak in stm32 qspi operations Zhang Qilong
2020-11-06 12:38 ` Patrice CHOTARD [this message]
2020-11-09 19:48 ` 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=76ebfa03-59d0-ed49-fa9b-87d9dd9f21f7@st.com \
--to=patrice.chotard@st.com \
--cc=alexandre.torgue@st.com \
--cc=broonie@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-spi@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=zhangqilong3@huawei.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;
as well as URLs for NNTP newsgroup(s).