Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2358412pxj; Sun, 30 May 2021 23:29:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxItTL2E9ny+ZzM708poeZLrHqE9IspAb4g1ZvHrXOz26Eu9l9BrfprryaC16LXkTlBzo5J X-Received: by 2002:a17:906:2da1:: with SMTP id g1mr20814409eji.47.1622442594007; Sun, 30 May 2021 23:29:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622442594; cv=none; d=google.com; s=arc-20160816; b=XeXpYDAm97sWja1owHBrFp1Ab32ePoXrdKSyHymJ9xH5/6BIO22e4FFfy9HWnyDt9r AJIT32aj7G2r7eWiV4Fzdb6Ksgk7sVs/ZtbRA3SqMfkhZ2BM5vRoA43zdB6k/9vVbiZq zpcmeY6EWbq/c9+16RUphdfWMzAWJEXVqBvmG6sQF4X/E8p/Q9Hu5yqHIFQEQ6Bwb53x v3ZihEPqOs33r5DzSv8wd1qeBC5VlhuwgMRnuaxecFcTKPrukPr1xvfTdjiOGevxb+nb zvIRzRqgaOVnBSRxyGcxfI1iaof3hHjXHlxlQ2cVmJGG92K5r+y9kety/Mf/IxImtHTn o4/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=AJa0PiIYJoZuFBsG32s2GGjRCAl2NiqYY4T5ujNNKGw=; b=0qMHLHDsGOmzOCM8ANvzH5aibQgmRT0ZIIpHWjbLQpvQStWeOWHg6yY/V33z4Trkop m84xgZO6+AYCI0PzF2tuD3HqKsU4/OR61miH6JCHlLV+1/H36H38y54+EbM+e8twkd1O i4T/gQiuuRVUsQWtHlRMZFYzyxogwmauhxAr4GNBMI4+ndMB82YP2z7bEAUXzHaYQogz vun8UVRx0l2FrL/wHiVgD0mPh+UW15M/9kJ5FgSTpZG1HRrm/voLnsf66mH8gznYfIHV ajc6NTNCd3zCDBV91SZ6/6gfGIwdB0F7XwkzWREFjLJ9WfbcVm9NOAA7NAKPC23WK/3Q zefQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e22si8206610ejt.735.2021.05.30.23.29.31; Sun, 30 May 2021 23:29:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230132AbhEaG2S (ORCPT + 99 others); Mon, 31 May 2021 02:28:18 -0400 Received: from szxga01-in.huawei.com ([45.249.212.187]:2797 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230091AbhEaG2P (ORCPT ); Mon, 31 May 2021 02:28:15 -0400 Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4FtlYt5qkyzWpwk; Mon, 31 May 2021 14:21:54 +0800 (CST) Received: from dggemi762-chm.china.huawei.com (10.1.198.148) by dggemv711-chm.china.huawei.com (10.1.198.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2176.2; Mon, 31 May 2021 14:26:34 +0800 Received: from linux-lmwb.huawei.com (10.175.103.112) by dggemi762-chm.china.huawei.com (10.1.198.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Mon, 31 May 2021 14:26:34 +0800 From: Zou Wei To: , , CC: , , , , "Zou Wei" Subject: [PATCH -next] dmaengine: stm32-dma: fix PM reference leak in stm32_dma_alloc_chan_resource() Date: Mon, 31 May 2021 14:45:15 +0800 Message-ID: <1622443515-55117-1-git-send-email-zou_wei@huawei.com> X-Mailer: git-send-email 2.6.2 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.103.112] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggemi762-chm.china.huawei.com (10.1.198.148) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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: Zou Wei --- drivers/dma/stm32-dma.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/dma/stm32-dma.c b/drivers/dma/stm32-dma.c index f54ecb1..7dd1d3d 100644 --- a/drivers/dma/stm32-dma.c +++ b/drivers/dma/stm32-dma.c @@ -1200,7 +1200,7 @@ static int stm32_dma_alloc_chan_resources(struct dma_chan *c) chan->config_init = false; - ret = pm_runtime_get_sync(dmadev->ddev.dev); + ret = pm_runtime_resume_and_get(dmadev->ddev.dev); if (ret < 0) return ret; @@ -1470,7 +1470,7 @@ static int stm32_dma_suspend(struct device *dev) struct stm32_dma_device *dmadev = dev_get_drvdata(dev); int id, ret, scr; - ret = pm_runtime_get_sync(dev); + ret = pm_runtime_resume_and_get(dev); if (ret < 0) return ret; -- 2.6.2