From patchwork Mon May 17 08:18:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Kuai X-Patchwork-Id: 12261193 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=-17.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, 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 AD957C433B4 for ; Mon, 17 May 2021 08:27:42 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 7A10361057 for ; Mon, 17 May 2021 08:27:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7A10361057 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID:Date: Subject:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=C2STEabm2I4ee/29V6XpG0rqA3fff85GqSiIF709Hkk=; b=ZJ0ZVoMh9cgFDEd9mGR/rCj44 BndVE49bAXcaFTq4B2PiwpuV+ayg3xHxmWEZ9Blm5opScd4Ec/zmqkrAJXyx4rReixw/uQhiIkRDf zxdaEsuYHBopsYSTtxPMQUBb9IpN2ez/XLU8e75764rPin4ZWCRq55Ihrn0x1+o6DbiyfHuHnk8IL m/a7KWW4cQw+q6uvG2oPcM+dZcIyPfU2Y0ghU6f/r0icB2nlZkNY70i/3oJXiyCqIJeSvsrON4BAJ UfGZNO2S2wRhQFcnCveyd7+mVf7xvijUzN/ehNr6finH0ZgiuSmIcxkeFMMadmrXIPqCEGR5Y6cVi dDSdmqizA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1liYZS-00EDyQ-Ru; Mon, 17 May 2021 08:25:51 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1liYLI-00EAyZ-EP for linux-arm-kernel@desiato.infradead.org; Mon, 17 May 2021 08:11:13 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Type: Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date :Subject:CC:To:From:Sender:Reply-To:Content-ID:Content-Description; bh=ITPCvViDcMRNz6QsMdpWouX6vxMikjr8IsiBkQwZvrg=; b=hSp5M+Oz/p26RosEcLSnRS3auE vtqzsoLZPBkgn/n9UF3mnzbS3rmww1P8DHHdzidx/4NBdYcBVLxp7DIFv0oGMXaNuXyI1lTFVRXrJ 0yUOKeWt+LZr/+sOUw3NLazr+erTnnJX9huZ2yywQXh7Fk6OTr50RaeU9UkCL5OWIVpDM0lz38tqd vziT5X02KxC57Ms46m1BuCxzDmWVJIwQNMWpunJfCPPPAjDeXg6SL6wL1bV4Z60JXN8NsFkh9+Iqn QORKIfiiN102ldv/N2iBZyGOt/5lNq04uVetW80W5HI7O96j7l7OHdRTF/OdhzY3KF/DqY7cQCTXi 2XqsKQ+A==; Received: from szxga07-in.huawei.com ([45.249.212.35]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1liYLC-00Da1Y-C0 for linux-arm-kernel@lists.infradead.org; Mon, 17 May 2021 08:11:11 +0000 Received: from dggems705-chm.china.huawei.com (unknown [172.30.72.58]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4FkBb63RVlzCt5q; Mon, 17 May 2021 16:08:18 +0800 (CST) Received: from dggema762-chm.china.huawei.com (10.1.198.204) by dggems705-chm.china.huawei.com (10.3.19.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2176.2; Mon, 17 May 2021 16:11:00 +0800 Received: from huawei.com (10.175.127.227) by dggema762-chm.china.huawei.com (10.1.198.204) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Mon, 17 May 2021 16:11:00 +0800 From: Yu Kuai To: , , , CC: , , , , , Subject: [PATCH 1/3] dmaengine: stm32-mdma: fix PM reference leak in stm32_mdma_alloc_chan_resourc() Date: Mon, 17 May 2021 16:18:24 +0800 Message-ID: <20210517081826.1564698-2-yukuai3@huawei.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20210517081826.1564698-1-yukuai3@huawei.com> References: <20210517081826.1564698-1-yukuai3@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.127.227] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggema762-chm.china.huawei.com (10.1.198.204) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210517_011106_595764_854611D7 X-CRM114-Status: UNSURE ( 9.64 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org pm_runtime_get_sync will increment pm usage counter even it failed. Forgetting to putting operation will result in reference leak here. Fix it by replacing it with pm_runtime_resume_and_get to keep usage counter balanced. Reported-by: Hulk Robot Signed-off-by: Yu Kuai --- drivers/dma/stm32-mdma.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/dma/stm32-mdma.c b/drivers/dma/stm32-mdma.c index 36ba8b43e78d..18cbd1e43c2e 100644 --- a/drivers/dma/stm32-mdma.c +++ b/drivers/dma/stm32-mdma.c @@ -1452,7 +1452,7 @@ static int stm32_mdma_alloc_chan_resources(struct dma_chan *c) return -ENOMEM; } - ret = pm_runtime_get_sync(dmadev->ddev.dev); + ret = pm_runtime_resume_and_get(dmadev->ddev.dev); if (ret < 0) return ret; @@ -1718,7 +1718,7 @@ static int stm32_mdma_pm_suspend(struct device *dev) u32 ccr, id; int ret; - ret = pm_runtime_get_sync(dev); + ret = pm_runtime_resume_and_get(dev); if (ret < 0) return ret;