[PATCH] slimbus: qcom-ngd-ctrl: Fix error handling to keep reference balanced

Zhang Qilong zhangqilong3 at huawei.com
Sat Dec 5 13:22:45 CET 2020


In the error branch, we should call pm_runtime_put_noidle and
pm_runtime_disable to decrease usage counter and increase the
power disable depth to avoid reference leaks.

Fixes: 917809e2280bb ("slimbus: ngd: Add qcom SLIMBus NGD driver")
Signed-off-by: Zhang Qilong <zhangqilong3 at huawei.com>
---
 drivers/slimbus/qcom-ngd-ctrl.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/slimbus/qcom-ngd-ctrl.c b/drivers/slimbus/qcom-ngd-ctrl.c
index c054e83ab636..a9b4a1d95045 100644
--- a/drivers/slimbus/qcom-ngd-ctrl.c
+++ b/drivers/slimbus/qcom-ngd-ctrl.c
@@ -1483,7 +1483,7 @@ static int qcom_slim_ngd_probe(struct platform_device *pdev)
 	ret = qcom_slim_ngd_qmi_svc_event_init(ctrl);
 	if (ret) {
 		dev_err(&pdev->dev, "QMI service registration failed:%d", ret);
-		return ret;
+		goto pm_err;
 	}
 
 	INIT_WORK(&ctrl->m_work, qcom_slim_ngd_master_worker);
@@ -1500,6 +1500,9 @@ static int qcom_slim_ngd_probe(struct platform_device *pdev)
 	qcom_slim_ngd_qmi_svc_event_deinit(&ctrl->qmi);
 	if (ctrl->mwq)
 		destroy_workqueue(ctrl->mwq);
+pm_err:
+	pm_runtime_put_noidle(dev);
+	pm_runtime_disable(dev);
 
 	return ret;
 }
-- 
2.25.4



More information about the Alsa-devel mailing list