Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1191749pxu; Fri, 27 Nov 2020 01:46:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJyofnBp+NF9ilXaXe4EwpCjCdlms5yIgRCVg1nEa0dZ0gL6w6WaowECH3ohOAYeLKUE29Sy X-Received: by 2002:a17:906:4e52:: with SMTP id g18mr5095341ejw.385.1606470361051; Fri, 27 Nov 2020 01:46:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606470361; cv=none; d=google.com; s=arc-20160816; b=E25FgfZLK1NnlUs/82+HSmoXpal49yenN2pMPZwm5Y4SwUr0psA0/3aTC4lnFuMvp5 ZEKftkPZhtROqKbwRHlf6H8X7FXb9euglYEmwB+qvd6GG/KBvlN4BhZClGX12iytgn7q nZW3g6LBZko7iDNyBN7u3E9CBaDfbo2dkwTPzv8LfAruJIo1UZ7mWPvecyQMU9aTSan1 oxZY8Kr6nfUVxV0hynPpIxKoUBB+9vKs9lPztmQN9s6W1ttKr+CNSmCa3QTAWj12xthn lm0DxVbLOtcTZ/3QcE8iVvi4S18aSZJrUrIJ1/Jge4b8j+JDHbfnYSU8iSmJz0Ao3OtY EyeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=uDvKmgOBfOQiXDvdIJqnPmz2Ln6ubof1tH8MMNyo6CQ=; b=ejPRn3NuV/bi9VEGq6pwswY1W/0sPyfRG3kzx6L7JuiAeyxWfiQlyuhLK/cgb8Y28h Ni7yMv5jnaHH9cmjrQRR/z19frypyw6jaP62RJ149NfibParwmttRhSLaIAF3ljFd4JW Y1uGM2Xjz+cZ19csCDOgQccrxNVgBEE9czxaXsT9xggMJK3XLWakiv4xq28loy4INAGX wWwpHYMLsbRy5HzA/duwmVeeJq+kaAuBVHFiPdRmo/Giydyx151d6yVxrz2q2B0w6ILf 6rI4BawGH7T51W81ZLuuCgPYtDaF4dfVkG274npVQTc2Kf1xHjAYTFQVzQae1AnD2vsa yOfA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s15si4485676edx.431.2020.11.27.01.45.38; Fri, 27 Nov 2020 01:46:01 -0800 (PST) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729160AbgK0JlT (ORCPT + 99 others); Fri, 27 Nov 2020 04:41:19 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:8131 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728056AbgK0JlS (ORCPT ); Fri, 27 Nov 2020 04:41:18 -0500 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4Cj8ks6T81z15TQ7; Fri, 27 Nov 2020 17:40:53 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.487.0; Fri, 27 Nov 2020 17:41:09 +0800 From: Qinglang Miao To: Vinod Koul , Dan Williams , Maxime Coquelin , Alexandre Torgue CC: , , , , Qinglang Miao Subject: [PATCH 1/3] dmaengine: stm32-dma: fix reference leak in stm32_dma Date: Fri, 27 Nov 2020 17:45:23 +0800 Message-ID: <20201127094525.121388-2-miaoqinglang@huawei.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201127094525.121388-1-miaoqinglang@huawei.com> References: <20201127094525.121388-1-miaoqinglang@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.113.25] 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 a reference leak here. A new function pm_runtime_resume_and_get is introduced in [0] to keep usage counter balanced. So We fix the reference leak by replacing it with new funtion. [0] dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter") Fixes: 05f8740a0e6f ("dmaengine: stm32-dma: add suspend/resume power management support") Reported-by: Hulk Robot Signed-off-by: Qinglang Miao --- 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 d0055d2f0..1150aa90e 100644 --- a/drivers/dma/stm32-dma.c +++ b/drivers/dma/stm32-dma.c @@ -1187,7 +1187,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; @@ -1455,7 +1455,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.23.0