Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp191943pxf; Thu, 8 Apr 2021 00:20:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz9JTALKr4skZP+/mBxp5f5+OsRRGOoAve/Iec+BIHm3lz1+vG30hBtZOpl+IGWRPNb/r9C X-Received: by 2002:aa7:98c9:0:b029:242:18fc:562d with SMTP id e9-20020aa798c90000b029024218fc562dmr5930830pfm.39.1617866413503; Thu, 08 Apr 2021 00:20:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617866413; cv=none; d=google.com; s=arc-20160816; b=sTzg8bRQnnRvXdLcbbvffojJed8SyOISXOfQ949vqxsqflmQMytPeCiOhwOqFl9CxB t3UbsEMf/16g1J+bbCZuqgVee/DqdnYaqhBtaOy0GaQxEHvymq7vLYfSjSsTRFV9bgPR dPoELE3L39ksfxH2FjqT6xfBgrj4UY3SgMBxwJeqEU6K01zF6W5CaRGbrUI6KqCkiO5s +OVlNKDV4Jdj5Rl2jretZlcJlAcRfseh/9CD69CH0SC5ETghFCMj8JZa1qxFCTAetwE+ 8W7lgsA4MDRRRAy3O5iQfKRd9gw+diMRqf8vK6m+bCuRFhOMbqBPi/V7U5SzMyCPcywQ ouxA== 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 :message-id:date:subject:cc:to:from; bh=hgruXJ3IlKO1zpu5gyh9JO654wo3xYhAx91IEi6hLcc=; b=ejE3eogyceHzGbLcNWcfvJa/eaq+T+BaQWKdYc4zOXIbuBDKYHRv3S6jg4S3Xoncvg M9AyGJpcBNblyP1+INzGmhZ5ACuAA3nzs/mauyxLT9jOVRxTSfqpo8J2V+K7Ri7O3jXW qZdfPYPGWWxFGPCcpDrG3EkUOKCxoxNvqnD/8NEqcZviXQrwFLFJUhZDDU5J2oz/qxb0 FbycGMAyLicN3aJrdm12HXYLbUxEiEvYFlZRtUcO4NyNJAVgn5HTywP/t/UcH8rPFsax GDA/ZA3O3nPH13wArjzh0O+0UN1527Bp4CHXaxj3xjcdjSc1Xg1Bn/FVdKBS/9T0S+7E FxLQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-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 g9si27145246pgr.207.2021.04.08.00.20.00; Thu, 08 Apr 2021 00:20:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-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-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-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 S230239AbhDHHTb (ORCPT + 99 others); Thu, 8 Apr 2021 03:19:31 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:16080 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229775AbhDHHTa (ORCPT ); Thu, 8 Apr 2021 03:19:30 -0400 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4FGCJ271Msz1BGFm; Thu, 8 Apr 2021 15:17:06 +0800 (CST) Received: from huawei.com (10.175.113.32) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.498.0; Thu, 8 Apr 2021 15:19:08 +0800 From: Shixin Liu To: Herbert Xu , "David S. Miller" , Maxime Coquelin , "Alexandre Torgue" CC: , , , , Shixin Liu Subject: [PATCH -next 4/7] crypto: stm32/hash - Fix PM reference leak on stm32-hash.c Date: Thu, 8 Apr 2021 15:18:35 +0800 Message-ID: <20210408071835.836791-1-liushixin2@huawei.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.113.32] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-crypto@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. Signed-off-by: Shixin Liu --- drivers/crypto/stm32/stm32-hash.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/crypto/stm32/stm32-hash.c b/drivers/crypto/stm32/stm32-hash.c index 7ac0573ef663..389de9e3302d 100644 --- a/drivers/crypto/stm32/stm32-hash.c +++ b/drivers/crypto/stm32/stm32-hash.c @@ -813,7 +813,7 @@ static void stm32_hash_finish_req(struct ahash_request *req, int err) static int stm32_hash_hw_init(struct stm32_hash_dev *hdev, struct stm32_hash_request_ctx *rctx) { - pm_runtime_get_sync(hdev->dev); + pm_runtime_resume_and_get(hdev->dev); if (!(HASH_FLAGS_INIT & hdev->flags)) { stm32_hash_write(hdev, HASH_CR, HASH_CR_INIT); @@ -962,7 +962,7 @@ static int stm32_hash_export(struct ahash_request *req, void *out) u32 *preg; unsigned int i; - pm_runtime_get_sync(hdev->dev); + pm_runtime_resume_and_get(hdev->dev); while ((stm32_hash_read(hdev, HASH_SR) & HASH_SR_BUSY)) cpu_relax(); @@ -1000,7 +1000,7 @@ static int stm32_hash_import(struct ahash_request *req, const void *in) preg = rctx->hw_context; - pm_runtime_get_sync(hdev->dev); + pm_runtime_resume_and_get(hdev->dev); stm32_hash_write(hdev, HASH_IMR, *preg++); stm32_hash_write(hdev, HASH_STR, *preg++); @@ -1566,7 +1566,7 @@ static int stm32_hash_remove(struct platform_device *pdev) if (!hdev) return -ENODEV; - ret = pm_runtime_get_sync(hdev->dev); + ret = pm_runtime_resume_and_get(hdev->dev); if (ret < 0) return ret; -- 2.25.1