From patchwork Sat Dec 5 12:22:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Qilong X-Patchwork-Id: 11953073 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 741C0C433FE for ; Sat, 5 Dec 2020 12:20:47 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C1E6C23107 for ; Sat, 5 Dec 2020 12:20:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C1E6C23107 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id BF5E21792; Sat, 5 Dec 2020 13:19:52 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz BF5E21792 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1607170842; bh=NKdU4LZ7LZnj0qamHN65i0GB6rVa0Ega4I2aCQSivn0=; h=From:To:Subject:Date:Cc:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=obhRQZ14hDRUsRy7kAW5nRpMUEFqCd+EUr0sajp0E9fRhZ9fk3nUWEpIW03oj6Ize 9Ic45ggXtcDM+QwBRRD5pnFYy4vpdCsODFZKE2jvZbIEt+Ru60yWLKI/OYXeYl7IF3 5xjfxAApcGTs3q+MnI6/45X1EcZ7unF252MlTABM= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 25DEEF8016C; Sat, 5 Dec 2020 13:19:52 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id D22DBF8016D; Sat, 5 Dec 2020 13:19:50 +0100 (CET) Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id B9CE7F800E2 for ; Sat, 5 Dec 2020 13:19:39 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz B9CE7F800E2 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4Cp7sj1wgqz15JTv; Sat, 5 Dec 2020 20:19:05 +0800 (CST) Received: from huawei.com (10.175.127.227) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.487.0; Sat, 5 Dec 2020 20:19:29 +0800 From: Zhang Qilong To: , , Subject: [PATCH] slimbus: qcom-ngd-ctrl: Fix error handling to keep reference balanced Date: Sat, 5 Dec 2020 20:22:45 +0800 Message-ID: <20201205122245.2108188-1-zhangqilong3@huawei.com> X-Mailer: git-send-email 2.25.4 MIME-Version: 1.0 X-Originating-IP: [10.175.127.227] X-CFilter-Loop: Reflected Cc: linux-arm-msm@vger.kernel.org, alsa-devel@alsa-project.org X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" 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 --- 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; }