Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp3510070pxu; Mon, 30 Nov 2020 04:55:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJzCftsoJGBu6uwfW9TmBQ+PteJfa3i8618fA8eAUx/XR99DFmI9LYlq/eOHzHQsC30RvoAe X-Received: by 2002:a50:ccdb:: with SMTP id b27mr20854406edj.253.1606740924473; Mon, 30 Nov 2020 04:55:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606740924; cv=none; d=google.com; s=arc-20160816; b=PZTie53OIoperW3gbwc/7ZxlKMEUcNk6vei1Kv8Glc8MwEGCQib27YkLTxqlm6h134 1C820tzVTVXsoHp9ePGj5bzzPApNk4lFWVIqV9tZxyskA3uZdoyocpm8qybggyAgTonv bQfAlIPBnM/HENAsezCZHLTPwEFgvOHWlbNjGRPDCHTNkLPsfOkpheoqeLaHcej23K4s It4nRY+ZHJbB+ffnIMiUc6XZHYJcaQWJ3Qu0jbym4B60p5s0Vfd1eYVbrVaB9Mld3Aqt xKggCcgNmf/ZuPlwPxFmoMGWpKVaoby+WM/ig5Hg/e6qlfhkr/YEM8yuiVkTJm9ssfij siPg== 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=V/fV68QHbY2wgraFEZ0MAk8zM7VegWUjQHsVRAunhDE=; b=xqFOP2GoAVaRZ2xETN18qEisKgSaathvwWbWMyUS0LsiO88NiLDR9jyKCDnYSJvppp i96HthgGbqVVy5PUfjjBF2fNO+U01z+vRCtwRZPhE3+c9kil6KzuXp/XV+hSR4t2mQsJ fOFijrzEk1OytX/RduWMt0O3Z11JYr7nyix5DqE+B4rVEUJUDHcU3VdbGl0fToBlnltO Venq+vi0Q+XyDbG8rfFsj+iUjDx1Q6mYzYENLzEPF8qu8rRwjoZsfw61W8zABF5rFVpX sYdZYZfvE1prxcDGY5+OJP6sPrUvtAUlu+A9mFtdwL7hqPfN8wGX8VI5u+PdKUcQUc4w FWFw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f12si12336876edx.51.2020.11.30.04.55.00; Mon, 30 Nov 2020 04:55:24 -0800 (PST) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726260AbgK3MyI (ORCPT + 99 others); Mon, 30 Nov 2020 07:54:08 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:8533 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726001AbgK3MyG (ORCPT ); Mon, 30 Nov 2020 07:54:06 -0500 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4Cl4s658FgzhkdP; Mon, 30 Nov 2020 20:52:58 +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; Mon, 30 Nov 2020 20:53:16 +0800 From: Qinglang Miao To: =?UTF-8?q?=C5=81ukasz=20Stelmach?= , "Krzysztof Kozlowski" CC: , , , , Qinglang Miao Subject: [PATCH v2] hwrng: exynos - fix reference leak in exynos_trng_probe Date: Mon, 30 Nov 2020 21:01:18 +0800 Message-ID: <20201130130118.51339-1-miaoqinglang@huawei.com> X-Mailer: git-send-email 2.20.1 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-crypto@vger.kernel.org pm_runtime_get_sync will increment pm usage counter even failed. Forgetting to putting operation will result in a reference leak here. Replace it with pm_runtime_resume_and_get to keep usage counter balanced. I remove err_clock label at the same. Fixes: 6cd225cc5d8a ("hwrng: exynos - add Samsung Exynos True RNG driver") Reported-by: Hulk Robot Suggested-by: Lukasz Stelmach Signed-off-by: Qinglang Miao --- v2: remobe useless label as Lukasz suggested. drivers/char/hw_random/exynos-trng.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/char/hw_random/exynos-trng.c b/drivers/char/hw_random/exynos-trng.c index 8e1fe3f8d..ffebb72e4 100644 --- a/drivers/char/hw_random/exynos-trng.c +++ b/drivers/char/hw_random/exynos-trng.c @@ -132,7 +132,7 @@ static int exynos_trng_probe(struct platform_device *pdev) return PTR_ERR(trng->mem); pm_runtime_enable(&pdev->dev); - ret = pm_runtime_get_sync(&pdev->dev); + ret = pm_runtime_resume_and_get(&pdev->dev); if (ret < 0) { dev_err(&pdev->dev, "Could not get runtime PM.\n"); goto err_pm_get; @@ -142,13 +142,13 @@ static int exynos_trng_probe(struct platform_device *pdev) if (IS_ERR(trng->clk)) { ret = PTR_ERR(trng->clk); dev_err(&pdev->dev, "Could not get clock.\n"); - goto err_clock; + goto err_pm_get; } ret = clk_prepare_enable(trng->clk); if (ret) { dev_err(&pdev->dev, "Could not enable the clk.\n"); - goto err_clock; + goto err_pm_get; } ret = devm_hwrng_register(&pdev->dev, &trng->rng); @@ -164,9 +164,6 @@ static int exynos_trng_probe(struct platform_device *pdev) err_register: clk_disable_unprepare(trng->clk); -err_clock: - pm_runtime_put_sync(&pdev->dev); - err_pm_get: pm_runtime_disable(&pdev->dev); -- 2.23.0