Skip to contentSkip to conversation

dmaengine: sprd: handle the failure cases of pm_runtime_get_sync

PATCH New Navid Emamdoost 1 participant 1 message Jun 4, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dmaengine: sprd: handle the failure cases of pm_runtime_get_sync

Calling pm_runtime_get_sync increments the counter even in case of failure, causing incorrect ref count. Call pm_runtime_put if pm_runtime_get_sync fails.

---
 drivers/dma/sprd-dma.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/dma/sprd-dma.c +6 -2
index 0ef5ca81ba4d..0ba4fe1a1905 100644
@@ -1204,8 +1204,10 @@ static int sprd_dma_probe(struct platform_device *pdev)
 	pm_runtime_enable(&pdev->dev);
 
 	ret = pm_runtime_get_sync(&pdev->dev);
-	if (ret < 0)
+	if (ret < 0) {
+		pm_runtime_put_noidle(&pdev->dev);
 		goto err_rpm;
+	}
 
 	ret = dma_async_device_register(&sdev->dma_dev);
 	if (ret < 0) {
@@ -1239,8 +1241,10 @@ static int sprd_dma_remove(struct platform_device *pdev)
 	int ret;
 
 	ret = pm_runtime_get_sync(&pdev->dev);
-	if (ret < 0)
+	if (ret < 0) {
+		pm_runtime_put_noidle(&pdev->dev);
 		return ret;
+	}
 
 	/* explicitly free the irq */
 	if (sdev->irq > 0)
Signature · 1 line
2.17.1