[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20250124110213.1285417-1-mordan@ispras.ru>
Date: Fri, 24 Jan 2025 14:02:13 +0300
From: Vitalii Mordan <mordan@...ras.ru>
To: Vinod Koul <vkoul@...nel.org>
Cc: Vitalii Mordan <mordan@...ras.ru>,
Kunihiko Hayashi <hayashi.kunihiko@...ionext.com>,
Masami Hiramatsu <mhiramat@...nel.org>,
Masahiro Yamada <yamada.masahiro@...ionext.com>,
dmaengine@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org,
linux-kernel@...r.kernel.org,
lvc-project@...uxtesting.org,
Fedor Pchelkin <pchelkin@...ras.ru>,
Alexey Khoroshilov <khoroshilov@...ras.ru>,
Vadim Mutilin <mutilin@...ras.ru>
Subject: [PATCH] dma: uniphier-mdmac: fix call balance of mdev->clk handling routines
If the clock mdev->clk was enabled in uniphier_mdmac_probe(), it should be
disabled in any path. If dmaengine_terminate_sync() returns an error in
uniphier_mdmac_remove(), the clock mdev->clk will not be disabled.
Use the devm_clk_get_enabled() helper function to ensure proper call
balance for mdev->clk.
Found by Linux Verification Center (linuxtesting.org) with Klever.
Fixes: 32e74aabebc8 ("dmaengine: uniphier-mdmac: add UniPhier MIO DMAC driver")
Signed-off-by: Vitalii Mordan <mordan@...ras.ru>
---
drivers/dma/uniphier-mdmac.c | 15 ++++-----------
1 file changed, 4 insertions(+), 11 deletions(-)
diff --git a/drivers/dma/uniphier-mdmac.c b/drivers/dma/uniphier-mdmac.c
index 7a99f86ecb5a..471dc2ef4781 100644
--- a/drivers/dma/uniphier-mdmac.c
+++ b/drivers/dma/uniphier-mdmac.c
@@ -401,16 +401,12 @@ static int uniphier_mdmac_probe(struct platform_device *pdev)
if (IS_ERR(mdev->reg_base))
return PTR_ERR(mdev->reg_base);
- mdev->clk = devm_clk_get(dev, NULL);
+ mdev->clk = devm_clk_get_enabled(dev, NULL);
if (IS_ERR(mdev->clk)) {
- dev_err(dev, "failed to get clock\n");
+ dev_err(dev, "failed to get and enable clock\n");
return PTR_ERR(mdev->clk);
}
- ret = clk_prepare_enable(mdev->clk);
- if (ret)
- return ret;
-
ddev = &mdev->ddev;
ddev->dev = dev;
dma_cap_set(DMA_PRIVATE, ddev->cap_mask);
@@ -429,12 +425,12 @@ static int uniphier_mdmac_probe(struct platform_device *pdev)
for (i = 0; i < nr_chans; i++) {
ret = uniphier_mdmac_chan_init(pdev, mdev, i);
if (ret)
- goto disable_clk;
+ return ret;
}
ret = dma_async_device_register(ddev);
if (ret)
- goto disable_clk;
+ return ret;
ret = of_dma_controller_register(dev->of_node, of_dma_xlate_by_chan_id,
ddev);
@@ -447,8 +443,6 @@ static int uniphier_mdmac_probe(struct platform_device *pdev)
unregister_dmac:
dma_async_device_unregister(ddev);
-disable_clk:
- clk_disable_unprepare(mdev->clk);
return ret;
}
@@ -482,7 +476,6 @@ static void uniphier_mdmac_remove(struct platform_device *pdev)
of_dma_controller_free(pdev->dev.of_node);
dma_async_device_unregister(&mdev->ddev);
- clk_disable_unprepare(mdev->clk);
}
static const struct of_device_id uniphier_mdmac_match[] = {
--
2.25.1
Powered by blists - more mailing lists