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: 8574361 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: X-Original-To: patchwork-linux-crypto@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 9B38AC0553 for ; Mon, 14 Mar 2016 00:07:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C39432045E for ; Mon, 14 Mar 2016 00:07:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B8E1120460 for ; Mon, 14 Mar 2016 00:07:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754572AbcCNAHn (ORCPT ); Sun, 13 Mar 2016 20:07:43 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:16400 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754564AbcCNAHd (ORCPT ); Sun, 13 Mar 2016 20:07:33 -0400 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>; 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 Cc: Alan Stern , Krzysztof Kozlowski , stable@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= Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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)