lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:   Sun, 24 May 2020 14:02:23 +0800
From:   Dinghao Liu <dinghao.liu@....edu.cn>
To:     dinghao.liu@....edu.cn, kjlu@....edu
Cc:     Vinod Koul <vkoul@...nel.org>,
        Dan Williams <dan.j.williams@...el.com>,
        Maxime Coquelin <mcoquelin.stm32@...il.com>,
        Alexandre Torgue <alexandre.torgue@...com>,
        dmaengine@...r.kernel.org,
        linux-stm32@...md-mailman.stormreply.com,
        linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org
Subject: [PATCH] dmaengine: stm32-dmamux: Fix runtime PM imbalance on error

In stm32_dmamux_route_allocate(),  pm_runtime_get_sync() increments
the runtime PM usage counter even when it returns an error code.
Thus a pairing decrement is needed on the error handling path to
keep the counter balanced.

In stm32_dmamux_probe(), when platform_get_resource() returns an
error code, a pairing runtime PM usage counter decrement is needed
to keep the counter balanced. For error paths after this call,
things are the same.

Signed-off-by: Dinghao Liu <dinghao.liu@....edu.cn>
---
 drivers/dma/stm32-dmamux.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/dma/stm32-dmamux.c b/drivers/dma/stm32-dmamux.c
index 12f7637e13a1..e68e7078ff94 100644
--- a/drivers/dma/stm32-dmamux.c
+++ b/drivers/dma/stm32-dmamux.c
@@ -139,6 +139,7 @@ static void *stm32_dmamux_route_allocate(struct of_phandle_args *dma_spec,
 	spin_lock_irqsave(&dmamux->lock, flags);
 	ret = pm_runtime_get_sync(&pdev->dev);
 	if (ret < 0) {
+		pm_runtime_put_noidle(&pdev->dev);
 		spin_unlock_irqrestore(&dmamux->lock, flags);
 		goto error;
 	}
@@ -246,8 +247,10 @@ static int stm32_dmamux_probe(struct platform_device *pdev)
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	iomem = devm_ioremap_resource(&pdev->dev, res);
-	if (IS_ERR(iomem))
+	if (IS_ERR(iomem)) {
+		pm_runtime_put_noidle(&pdev->dev);
 		return PTR_ERR(iomem);
+	}
 
 	spin_lock_init(&stm32_dmamux->lock);
 
@@ -256,12 +259,14 @@ static int stm32_dmamux_probe(struct platform_device *pdev)
 		ret = PTR_ERR(stm32_dmamux->clk);
 		if (ret != -EPROBE_DEFER)
 			dev_err(&pdev->dev, "Missing clock controller\n");
+		pm_runtime_put_noidle(&pdev->dev);
 		return ret;
 	}
 
 	ret = clk_prepare_enable(stm32_dmamux->clk);
 	if (ret < 0) {
 		dev_err(&pdev->dev, "clk_prep_enable error: %d\n", ret);
+		pm_runtime_put_noidle(&pdev->dev);
 		return ret;
 	}
 
@@ -300,6 +305,7 @@ static int stm32_dmamux_probe(struct platform_device *pdev)
 	return 0;
 
 err_clk:
+	pm_runtime_put_noidle(&pdev->dev);
 	clk_disable_unprepare(stm32_dmamux->clk);
 
 	return ret;
-- 
2.17.1

Powered by blists - more mailing lists