From patchwork Mon Mar 14 00:07:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 8574471 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 32836C0553 for ; Mon, 14 Mar 2016 00:09:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4F1952044C for ; Mon, 14 Mar 2016 00:09:47 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 15C9F20460 for ; Mon, 14 Mar 2016 00:09:46 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1afG3I-00030k-A7; Mon, 14 Mar 2016 00:08:04 +0000 Received: from mailout1.w1.samsung.com ([210.118.77.11]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1afG36-0002y8-3F for linux-arm-kernel@lists.infradead.org; Mon, 14 Mar 2016 00:07:52 +0000 Received: from eucpsbgm2.samsung.com (unknown [203.254.199.245]) by mailout1.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0O40005IO5OHPZ80@mailout1.w1.samsung.com> for linux-arm-kernel@lists.infradead.org; Mon, 14 Mar 2016 00:07:29 +0000 (GMT) X-AuditID: cbfec7f5-f79b16d000005389-23-56e600c12383 Received: from eusync4.samsung.com ( [203.254.199.214]) by eucpsbgm2.samsung.com (EUCPMTA) with SMTP id BB.13.21385.1C006E65; Mon, 14 Mar 2016 00:07:29 +0000 (GMT) Received: from localhost.localdomain ([10.113.63.52]) by eusync4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0O4000AG95O6YG70@eusync4.samsung.com>; Mon, 14 Mar 2016 00:07:29 +0000 (GMT) From: Krzysztof Kozlowski To: Matt Mackall , Herbert Xu , Kukjin Kim , linux-crypto@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/4] hwrng: exynos - Fix unbalanced PM runtime put on timeout error path Date: Mon, 14 Mar 2016 09:07:13 +0900 Message-id: <1457914035-26856-2-git-send-email-k.kozlowski@samsung.com> X-Mailer: git-send-email 2.5.0 In-reply-to: <1457914035-26856-1-git-send-email-k.kozlowski@samsung.com> References: <1457914035-26856-1-git-send-email-k.kozlowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrKLMWRmVeSWpSXmKPExsVy+t/xa7oHGZ6FGbzZLWzR/UrG4vULQ4v+ x6+ZLTY9vsZqcf/eTyaLy7vmsFnMOL+PyWLBtj5GiwUbHzFaTPh9gc2By2PbAVWPTas62Tw2 L6n3mH33B6NH35ZVQOLlBkaPz5vkAtijuGxSUnMyy1KL9O0SuDJmvLvEWrCBp+LL84NMDYzT uLoYOTgkBEwkrs1V72LkBDLFJC7cW88GYgsJLGWU6P/nC2H/Z5S4uMwIxGYTMJbYvHwJUA0X h4jAN0aJHw/PMYIkmAWKJfpnrmcGsYUFYiUmrlrLDmKzCKhKLP+2iglkF6+Au8TtBleItXIS Cy6kg1RwCnhIHFqxnh1ilbvEhb2f2Scw8i5gZFjFKJpamlxQnJSea6RXnJhbXJqXrpecn7uJ ERJ4X3cwLj1mdYhRgINRiYf3x5qnYUKsiWXFlbmHGCU4mJVEeOf9BwrxpiRWVqUW5ccXleak Fh9ilOZgURLnnbnrfYiQQHpiSWp2ampBahFMlomDU6qB8ejFJMY/ezR8nkY6BB2MXL2gQOHE n+DaEOnzsxZyXeuPElTICZLmyPokvaq7UEWiqvxL+P3bhTyz9eVueyadMtmbpa0ZKujT877O cKePWMe/P8Jxa4t/ZK7bzNVne+DIzFdv7FuE9Xl939s2Baa6RJ7sDJ13aN3n2ZwzX858rXdv yY2MCzxflViKMxINtZiLihMBwnVLizgCAAA= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160313_170752_384087_90FC94C8 X-CRM114-Status: GOOD ( 16.50 ) X-Spam-Score: -6.9 (------) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Krzysztof Kozlowski , Alan Stern , stable@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In case of timeout during read operation, the exit path lacked PM runtime put. This could lead to unbalanced runtime PM usage counter thus leaving the device in an active state. Fixes: d7fd6075a205 ("hwrng: exynos - Add timeout for waiting on init done") Cc: # v4.4+ Signed-off-by: Krzysztof Kozlowski --- Changes since v1: 1. None. --- drivers/char/hw_random/exynos-rng.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/char/hw_random/exynos-rng.c b/drivers/char/hw_random/exynos-rng.c index d1fd21e99368..38b80f82ddd2 100644 --- a/drivers/char/hw_random/exynos-rng.c +++ b/drivers/char/hw_random/exynos-rng.c @@ -90,6 +90,7 @@ static int exynos_read(struct hwrng *rng, void *buf, struct exynos_rng, rng); u32 *data = buf; int retry = 100; + int ret = 4; pm_runtime_get_sync(exynos_rng->dev); @@ -98,17 +99,20 @@ static int exynos_read(struct hwrng *rng, void *buf, while (!(exynos_rng_readl(exynos_rng, EXYNOS_PRNG_STATUS_OFFSET) & PRNG_DONE) && --retry) cpu_relax(); - if (!retry) - return -ETIMEDOUT; + if (!retry) { + ret = -ETIMEDOUT; + goto out; + } exynos_rng_writel(exynos_rng, PRNG_DONE, EXYNOS_PRNG_STATUS_OFFSET); *data = exynos_rng_readl(exynos_rng, EXYNOS_PRNG_OUT1_OFFSET); +out: pm_runtime_mark_last_busy(exynos_rng->dev); pm_runtime_put_sync_autosuspend(exynos_rng->dev); - return 4; + return ret; } static int exynos_rng_probe(struct platform_device *pdev)