Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2356264pxj; Sun, 30 May 2021 23:25:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwZngNVeci1z+muAiPzVDYB0HQAlhd6YjVr3GgIEW9Lx1/r5PZlSfZZAW/mz7loXauM4hcO X-Received: by 2002:a05:6402:2814:: with SMTP id h20mr24106848ede.102.1622442318106; Sun, 30 May 2021 23:25:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622442318; cv=none; d=google.com; s=arc-20160816; b=nLrg9XYIbn/L8Yj832UfRTsI5onFJpvor/mZHXYgnQVeKlyESSa1mRKyCaPwuhSiUf T2n/IZUolMs5+R6E73PYcweBUbwLXQoDPCnkrhj8ZdEtlnLFGE4ATBbDYLzr89xwA/hx mtjsp1ZKlKQFyq6p50McP4NipkMh89Pz3TDjpU9gQD1azdNYg+yFi3Vq1oUWiaYZh8uO z9ek40OolBwHzQvlw3dVfR3QZm9CEd4sgxsZ/lipxqZWS84aSACXHMhjtZ3Di5j92axy 8R8PO5hFMwu4fhASjpqi0sJwyLnMYGa0djppI0BLZ4zhZuxAIOVYMDhB3oSvQYtnai5M rWJA== 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=fWDH6Qoq5ZOeZ/kqK7WQRxinFizTzK6Rh+tcMmSqGME=; b=lon/DkD6nJt/hd0p1TYdxX/mpLLHlie8WmE+6Uqi/nad9hDxwU42sJDaUfXg2/ayb1 ko7HOiqxAn7PAH9+3QT2d+NF+j1wBccqMUNLsRrw9M0RXuMya1ZKPf+/sB6OiBCXReyj JqbGlVdTDD27/sJUVDcS0HgpWkfPlTmaZ+0bG+uiHVymj2JBxp5WLpB/qzr71jJqggMm oHPttAqr86WlwmCeNVWmttdIMCPDUJTOXVSI235HKxGSPQSyvQe+60BWZYf86ZNk7OpS 0C+mlVIP409dRiC6U+pjM/sOjLKgWqMe956c1UXwM4c3ugUiBww8ntNqB2EJOnBUXwrm 825g== 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 p2si7849622ejx.16.2021.05.30.23.24.55; Sun, 30 May 2021 23:25:18 -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 S230165AbhEaGZ1 (ORCPT + 99 others); Mon, 31 May 2021 02:25:27 -0400 Received: from szxga01-in.huawei.com ([45.249.212.187]:6090 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230070AbhEaGZ0 (ORCPT ); Mon, 31 May 2021 02:25:26 -0400 Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4FtlXt5G7HzYndR; Mon, 31 May 2021 14:21:02 +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:23:39 +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:23:39 +0800 From: Zou Wei To: , , CC: , , , , "Zou Wei" Subject: [PATCH -next] dmaengine: stm32-dmamux: fix PM reference leak in stm32_dmamux_route_allocate() Date: Mon, 31 May 2021 14:42:20 +0800 Message-ID: <1622443340-54803-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: dggems705-chm.china.huawei.com (10.3.19.182) 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-dmamux.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/dma/stm32-dmamux.c b/drivers/dma/stm32-dmamux.c index ef0d055..8fd60a6 100644 --- a/drivers/dma/stm32-dmamux.c +++ b/drivers/dma/stm32-dmamux.c @@ -137,7 +137,7 @@ static void *stm32_dmamux_route_allocate(struct of_phandle_args *dma_spec, /* Set dma request */ spin_lock_irqsave(&dmamux->lock, flags); - ret = pm_runtime_get_sync(&pdev->dev); + ret = pm_runtime_resume_and_get(&pdev->dev); if (ret < 0) { spin_unlock_irqrestore(&dmamux->lock, flags); goto error; @@ -361,7 +361,7 @@ static int stm32_dmamux_resume(struct device *dev) if (ret < 0) return ret; - ret = pm_runtime_get_sync(dev); + ret = pm_runtime_resume_and_get(dev); if (ret < 0) return ret; -- 2.6.2