From patchwork Fri Oct 30 15:36:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Qilong X-Patchwork-Id: 11876137 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=-12.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,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 E6FBAC2D0A3 for ; Tue, 3 Nov 2020 07:47:08 +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 0303E2222B for ; Tue, 3 Nov 2020 07:47:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="Qch8WuDF" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0303E2222B 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 418531767; Tue, 3 Nov 2020 08:46:16 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 418531767 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1604389626; bh=/291h87g6Lm0Cx/bEUdDLObeGt9RL5v9y7XeTphzwQk=; h=From:To:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=Qch8WuDFwmHHEyIpdVgttAH65yRe4C5pSvDwjKwJErLga1bZP/bfXyK01SJRLfPIG YoNvoqRH+hAUEk2wAIebIpZlJnqmMIcnktxwYQelMh4wkP/UrWsuDHmRuKOChGjgF0 VGr7FhBORruwcX+st1RJCaryhu7B6zGjb6WyM6V4= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 97833F8028D; Tue, 3 Nov 2020 08:45:25 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 5BAF9F801D5; Fri, 30 Oct 2020 16:26:13 +0100 (CET) Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id E5A55F800C0 for ; Fri, 30 Oct 2020 16:26:05 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz E5A55F800C0 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4CN5jm4vPWzhb43; Fri, 30 Oct 2020 23:25:48 +0800 (CST) Received: from huawei.com (10.90.53.225) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.487.0; Fri, 30 Oct 2020 23:25:41 +0800 From: Zhang Qilong To: , , , , , Subject: [PATCH] ASoC: ti: davinci-mcasp: fix possible reference leak in __davinci_mcasp_set_clkdiv Date: Fri, 30 Oct 2020 23:36:26 +0800 Message-ID: <20201030153626.94150-1-zhangqilong3@huawei.com> X-Mailer: git-send-email 2.26.0.106.g9fadedd MIME-Version: 1.0 X-Originating-IP: [10.90.53.225] X-CFilter-Loop: Reflected X-Mailman-Approved-At: Tue, 03 Nov 2020 08:45:21 +0100 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" pm_runtime_get_sync() will increment pm usage counter whatever it does. Forgetting to call pm_runtime_put will result in reference leak in __davinci_mcasp_set_clkdiv, so we should fix it. Signed-off-by: Zhang Qilong --- sound/soc/ti/davinci-mcasp.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sound/soc/ti/davinci-mcasp.c b/sound/soc/ti/davinci-mcasp.c index a6b72ad53b43..4b46dd827f3f 100644 --- a/sound/soc/ti/davinci-mcasp.c +++ b/sound/soc/ti/davinci-mcasp.c @@ -607,6 +607,8 @@ static int davinci_mcasp_set_dai_fmt(struct snd_soc_dai *cpu_dai, static int __davinci_mcasp_set_clkdiv(struct davinci_mcasp *mcasp, int div_id, int div, bool explicit) { + int ret = 0; + pm_runtime_get_sync(mcasp->dev); switch (div_id) { case MCASP_CLKDIV_AUXCLK: /* MCLK divider */ @@ -644,11 +646,11 @@ static int __davinci_mcasp_set_clkdiv(struct davinci_mcasp *mcasp, int div_id, break; default: - return -EINVAL; + ret = -EINVAL; } pm_runtime_put(mcasp->dev); - return 0; + return ret; } static int davinci_mcasp_set_clkdiv(struct snd_soc_dai *dai, int div_id,