From: Jon Hunter <jonathanh@nvidia.com>
To: Qinglang Miao <miaoqinglang@huawei.com>,
Laxman Dewangan <ldewangan@nvidia.com>,
Vinod Koul <vkoul@kernel.org>,
Dan Williams <dan.j.williams@intel.com>,
Thierry Reding <thierry.reding@gmail.com>
Cc: <dmaengine@vger.kernel.org>, <linux-tegra@vger.kernel.org>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] dmaengine: tegra-apb: fix reference leak in tegra_dma_issue_pending and tegra_dma_synchronize
Date: Mon, 30 Nov 2020 11:12:45 +0000 [thread overview]
Message-ID: <b7871cf9-9f3e-1b8e-028b-73bd703411f7@nvidia.com> (raw)
In-Reply-To: <20201127094431.120771-1-miaoqinglang@huawei.com>
On 27/11/2020 09:44, Qinglang Miao wrote:
> pm_runtime_get_sync will increment pm usage counter even it
> failed. Forgetting to putting operation will result in a
> reference leak here.
>
> A new function pm_runtime_resume_and_get is introduced in
> [0] to keep usage counter balanced. So We fix the reference
> leak by replacing it with new funtion.
>
> [0] dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter")
>
> Fixes: 84a3f375eea9 ("dmaengine: tegra-apb: Keep clock enabled only during of DMA transfer")
> Fixes: 664475cffb8c ("dmaengine: tegra-apb: Ensure that clock is enabled during of DMA synchronization")
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Qinglang Miao <miaoqinglang@huawei.com>
> ---
> drivers/dma/tegra20-apb-dma.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/dma/tegra20-apb-dma.c b/drivers/dma/tegra20-apb-dma.c
> index 71827d9b0..b7260749e 100644
> --- a/drivers/dma/tegra20-apb-dma.c
> +++ b/drivers/dma/tegra20-apb-dma.c
> @@ -723,7 +723,7 @@ static void tegra_dma_issue_pending(struct dma_chan *dc)
> goto end;
> }
> if (!tdc->busy) {
> - err = pm_runtime_get_sync(tdc->tdma->dev);
> + err = pm_runtime_resume_and_get(tdc->tdma->dev);
> if (err < 0) {
> dev_err(tdc2dev(tdc), "Failed to enable DMA\n");
> goto end;
> @@ -818,7 +818,7 @@ static void tegra_dma_synchronize(struct dma_chan *dc)
> struct tegra_dma_channel *tdc = to_tegra_dma_chan(dc);
> int err;
>
> - err = pm_runtime_get_sync(tdc->tdma->dev);
> + err = pm_runtime_resume_and_get(tdc->tdma->dev);
> if (err < 0) {
> dev_err(tdc2dev(tdc), "Failed to synchronize DMA: %d\n", err);
> return;
Reviewed-by: Jon Hunter <jonathanh@nvidia.com>
Cheers
Jon
--
nvpublic
prev parent reply other threads:[~2020-11-30 11:13 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-27 9:44 Qinglang Miao
2020-11-30 11:12 ` Jon Hunter [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=b7871cf9-9f3e-1b8e-028b-73bd703411f7@nvidia.com \
--to=jonathanh@nvidia.com \
--cc=dan.j.williams@intel.com \
--cc=dmaengine@vger.kernel.org \
--cc=ldewangan@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=miaoqinglang@huawei.com \
--cc=thierry.reding@gmail.com \
--cc=vkoul@kernel.org \
/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®