Re: [PATCH] dmaengine: sprd: fix clock imbalance when enabling ashb_clk fails

Frank Li <[email protected]>
Newsgroups org.kernel.vger.dmaengine,org.kernel.vger.linux-kernel
Message-ID <an3zMHoaxx4XzvpK@SMW015318>
On Thu, Aug 13, 2026 at 10:53:54AM +0000, Chaithanya Lagisetty wrote:
> [You don't often get email from [email protected]. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
>
> sprd_dma_enable() enables sdev->clk and then enables the optional
> ashb_clk. If clk_prepare_enable() for ashb_clk fails, the function
> returns the error without disabling sdev->clk, which was already
> enabled. Both callers (probe and resume) treat a non-zero return as
> "nothing was enabled" and bail out, so sdev->clk is leaked.
>
> Disable sdev->clk on the ashb_clk enable failure path.
>
> Fixes: 9b3b8171f7f4 ("dmaengine: sprd: Add Spreadtrum DMA driver")
> Signed-off-by: Chaithanya Lagisetty <[email protected]>
> ---
>  drivers/dma/sprd-dma.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/dma/sprd-dma.c b/drivers/dma/sprd-dma.c
> index 087fea3af2e4..3ea5c3ba1a8c 100644
> --- a/drivers/dma/sprd-dma.c
> +++ b/drivers/dma/sprd-dma.c
> @@ -270,9 +270,16 @@ static int sprd_dma_enable(struct sprd_dma_dev *sdev)
>          * The ashb_clk is optional and only for AGCP DMA controller, so we
>          * need add one condition to check if the ashb_clk need enable.
>          */
> -       if (!IS_ERR(sdev->ashb_clk))
> +       if (!IS_ERR(sdev->ashb_clk)) {
>                 ret = clk_prepare_enable(sdev->ashb_clk);
> +               if (ret)
> +                       goto disable_clk;
> +       }
>
> +       return 0;
> +
> +disable_clk:
> +       clk_disable_unprepare(sdev->clk);

Convert to clk bulk API.

Frank
>         return ret;
>  }
>
> --
> 2.43.0
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.