@@ -476,16 +476,12 @@ static int milbeaut_hdmac_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_SLAVE, ddev->cap_mask);
@@ -507,12 +503,12 @@ static int milbeaut_hdmac_probe(struct platform_device *pdev)
for (i = 0; i < nr_chans; i++) {
ret = milbeaut_hdmac_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,
milbeaut_hdmac_xlate, mdev);
@@ -525,8 +521,6 @@ static int milbeaut_hdmac_probe(struct platform_device *pdev)
unregister_dmac:
dma_async_device_unregister(ddev);
-disable_clk:
- clk_disable_unprepare(mdev->clk);
return ret;
}
@@ -560,7 +554,6 @@ static void milbeaut_hdmac_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 milbeaut_hdmac_match[] = {
If the clock mdev->clk was enabled in milbeaut_hdmac_probe(), it should be disabled in any path. If dmaengine_terminate_sync() returns an error in milbeaut_hdmac_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: 6c3214e698e4 ("dmaengine: milbeaut-hdmac: Add HDMAC driver for Milbeaut platforms") Signed-off-by: Vitalii Mordan <mordan@ispras.ru> --- drivers/dma/milbeaut-hdmac.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-)