Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp191697pxf; Thu, 8 Apr 2021 00:19:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwvZNdf9nhbmGtTB8tbmRi7ukTJEKGczilgzMEvVvrLSOWVAMdRTAqJLH16KHZsSLEn6Elv X-Received: by 2002:a05:6402:d07:: with SMTP id eb7mr9333668edb.242.1617866387472; Thu, 08 Apr 2021 00:19:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617866387; cv=none; d=google.com; s=arc-20160816; b=WxenRdjSHvqblflCQ41o9eLar7k7vsr81l2RHmYuZwkaq5vz1IyfzOEBqOO91Wxpq0 s1h1dipZYjzMkR+OVMtPKSw5o0gHbMZcKVq2vSgR+DxKRZrRiMFAb31o854s4AiGDQ4X U3ilT5JX479kH5oDAB2h+E2bfqft8d4yIaunSbE7wqalnhogQw+4BUMMflfGP/16+kC4 wo5wqDc052jh4RxMr5Wwf8Pw00bZZaffqB9uOZG1d3hL8QMZIn1LguLqQ3cubQ6yrYUi sIao0ExyL632yFoV9aRyZu3B1tT2RW63MTG9PEFEYNKedUCtMskRQIWqQVFt3hGoatW0 7hqA== 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=ZZAkSCHbmWoLWzWgNaO9SWJ1gr+lF0L6qTMrRgGoEgc=; b=YhXUtgP5SV+s4p8sfVlo4JPDEF1cm4OynPrbL09n/XX37o01mLd1sNYJoG8yWMCP9n nhuXnImk1ppY3UU6kg5yG+q6Qlv9sJfVELN2YKjCfJ6Xn7gKAF9j2Tms0F2Hglo1PFQB 9s1OLrsR2hR3+XAOkNdhOg4N9sWAwfAHxk4HSlr6TXS3BFME2AC6nAop7TvszOdkW+/7 OMbdOOLReLPOKGrP69k2rf1Cttm5kzBO80jSunx1jmpCF3cn5/RiGadF+iHDgQA6Unq0 V8J1l4O98hAahK54RFXd2qNBbe6V0ieLeRxWlOGpibjZigT/BYVlGqkQAXzWdoQwImNC iyTw== 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 r1si6888235eds.382.2021.04.08.00.19.22; Thu, 08 Apr 2021 00:19:47 -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 S229517AbhDHHTX (ORCPT + 99 others); Thu, 8 Apr 2021 03:19:23 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:16038 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229506AbhDHHTX (ORCPT ); Thu, 8 Apr 2021 03:19:23 -0400 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4FGCHC6DwfzPnwx; Thu, 8 Apr 2021 15:16:23 +0800 (CST) Received: from huawei.com (10.175.113.32) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.498.0; Thu, 8 Apr 2021 15:19:04 +0800 From: Shixin Liu To: Corentin Labbe , Herbert Xu , "David S. Miller" , Maxime Ripard , Chen-Yu Tsai , "Jernej Skrabec" CC: , , , , Shixin Liu Subject: [PATCH -next 1/7] crypto: sun4i-ss - Fix PM reference leak when pm_runtime_get_sync() fails Date: Thu, 8 Apr 2021 15:18:31 +0800 Message-ID: <20210408071831.836638-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/allwinner/sun4i-ss/sun4i-ss-cipher.c | 2 +- drivers/crypto/allwinner/sun4i-ss/sun4i-ss-core.c | 2 +- drivers/crypto/allwinner/sun4i-ss/sun4i-ss-hash.c | 2 +- drivers/crypto/allwinner/sun4i-ss/sun4i-ss-prng.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/crypto/allwinner/sun4i-ss/sun4i-ss-cipher.c b/drivers/crypto/allwinner/sun4i-ss/sun4i-ss-cipher.c index c2e6f5ed1d79..dec79fa3ebaf 100644 --- a/drivers/crypto/allwinner/sun4i-ss/sun4i-ss-cipher.c +++ b/drivers/crypto/allwinner/sun4i-ss/sun4i-ss-cipher.c @@ -561,7 +561,7 @@ int sun4i_ss_cipher_init(struct crypto_tfm *tfm) sizeof(struct sun4i_cipher_req_ctx) + crypto_skcipher_reqsize(op->fallback_tfm)); - err = pm_runtime_get_sync(op->ss->dev); + err = pm_runtime_resume_and_get(op->ss->dev); if (err < 0) goto error_pm; diff --git a/drivers/crypto/allwinner/sun4i-ss/sun4i-ss-core.c b/drivers/crypto/allwinner/sun4i-ss/sun4i-ss-core.c index ef224d5e4903..44b8fc4b786d 100644 --- a/drivers/crypto/allwinner/sun4i-ss/sun4i-ss-core.c +++ b/drivers/crypto/allwinner/sun4i-ss/sun4i-ss-core.c @@ -454,7 +454,7 @@ static int sun4i_ss_probe(struct platform_device *pdev) * this info could be useful */ - err = pm_runtime_get_sync(ss->dev); + err = pm_runtime_resume_and_get(ss->dev); if (err < 0) goto error_pm; diff --git a/drivers/crypto/allwinner/sun4i-ss/sun4i-ss-hash.c b/drivers/crypto/allwinner/sun4i-ss/sun4i-ss-hash.c index c1b4585e9bbc..d28292762b32 100644 --- a/drivers/crypto/allwinner/sun4i-ss/sun4i-ss-hash.c +++ b/drivers/crypto/allwinner/sun4i-ss/sun4i-ss-hash.c @@ -27,7 +27,7 @@ int sun4i_hash_crainit(struct crypto_tfm *tfm) algt = container_of(alg, struct sun4i_ss_alg_template, alg.hash); op->ss = algt->ss; - err = pm_runtime_get_sync(op->ss->dev); + err = pm_runtime_resume_and_get(op->ss->dev); if (err < 0) return err; diff --git a/drivers/crypto/allwinner/sun4i-ss/sun4i-ss-prng.c b/drivers/crypto/allwinner/sun4i-ss/sun4i-ss-prng.c index 443160a114bb..491fcb7b81b4 100644 --- a/drivers/crypto/allwinner/sun4i-ss/sun4i-ss-prng.c +++ b/drivers/crypto/allwinner/sun4i-ss/sun4i-ss-prng.c @@ -29,7 +29,7 @@ int sun4i_ss_prng_generate(struct crypto_rng *tfm, const u8 *src, algt = container_of(alg, struct sun4i_ss_alg_template, alg.rng); ss = algt->ss; - err = pm_runtime_get_sync(ss->dev); + err = pm_runtime_resume_and_get(ss->dev); if (err < 0) return err; -- 2.25.1