[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <b7871cf9-9f3e-1b8e-028b-73bd703411f7@nvidia.com>
Date: Mon, 30 Nov 2020 11:12:45 +0000
From: Jon Hunter <jonathanh@...dia.com>
To: Qinglang Miao <miaoqinglang@...wei.com>,
Laxman Dewangan <ldewangan@...dia.com>,
Vinod Koul <vkoul@...nel.org>,
Dan Williams <dan.j.williams@...el.com>,
Thierry Reding <thierry.reding@...il.com>
CC: <dmaengine@...r.kernel.org>, <linux-tegra@...r.kernel.org>,
<linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] dmaengine: tegra-apb: fix reference leak in
tegra_dma_issue_pending and tegra_dma_synchronize
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@...wei.com>
> Signed-off-by: Qinglang Miao <miaoqinglang@...wei.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@...dia.com>
Cheers
Jon
--
nvpublic
Powered by blists - more mailing lists