From patchwork Fri Mar 11 07:49:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 8562781 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: X-Original-To: patchwork-linux-crypto@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 8E8869FDD5 for ; Fri, 11 Mar 2016 07:49:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C795620268 for ; Fri, 11 Mar 2016 07:49:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D83A12035E for ; Fri, 11 Mar 2016 07:49:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934504AbcCKHtv (ORCPT ); Fri, 11 Mar 2016 02:49:51 -0500 Received: from mailout3.w1.samsung.com ([210.118.77.13]:8367 "EHLO mailout3.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934483AbcCKHto (ORCPT ); Fri, 11 Mar 2016 02:49:44 -0500 Received: from eucpsbgm2.samsung.com (unknown [203.254.199.245]) by mailout3.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0O3V00DA072TFI60@mailout3.w1.samsung.com>; Fri, 11 Mar 2016 07:49:41 +0000 (GMT) X-AuditID: cbfec7f5-f79b16d000005389-6a-56e2789553cc Received: from eusync2.samsung.com ( [203.254.199.212]) by eucpsbgm2.samsung.com (EUCPMTA) with SMTP id 5C.5F.21385.59872E65; Fri, 11 Mar 2016 07:49:41 +0000 (GMT) Received: from localhost.localdomain ([10.113.63.52]) by eusync2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0O3V00KWE72HYU40@eusync2.samsung.com>; Fri, 11 Mar 2016 07:49:41 +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: Krzysztof Kozlowski , stable@vger.kernel.org Subject: [PATCH 3/5] hwrng: exynos - Fix unbalanced PM runtime put on timeout error path Date: Fri, 11 Mar 2016 16:49:20 +0900 Message-id: <1457682562-21219-3-git-send-email-k.kozlowski@samsung.com> X-Mailer: git-send-email 2.5.0 In-reply-to: <1457682562-21219-1-git-send-email-k.kozlowski@samsung.com> References: <1457682562-21219-1-git-send-email-k.kozlowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprPLMWRmVeSWpSXmKPExsVy+t/xK7pTKx6FGZy/JmrR/UrG4vULQ4v+ x6+ZLTY9vsZqcf/eTyaLy7vmsFnMOL+PyWLBtj5GiwUbHzE6cHpsO6DqsWlVJ5vH5iX1Hn1b VjF69L3cwOjxeZNcAFsUl01Kak5mWWqRvl0CV8bRJ9OYCrp4KrZef8DcwPiXs4uRk0NCwESi 7/9WRghbTOLCvfVsXYxcHEICSxkljkxawQjh/GeU+HxiDytIFZuAscTm5UvAqkQEvjFK/Hh4 DqydWcBT4t3fh+wgtrBAlMTW6S+YQWwWAVWJVb/+gdXwCrhLnHu2FGgQB9A6OYkFF9JBwpwC HhKNWz6xgdhCQCUrbx5lm8DIu4CRYRWjaGppckFxUnqukV5xYm5xaV66XnJ+7iZGSLB93cG4 9JjVIUYBDkYlHt4P1x6GCbEmlhVX5h5ilOBgVhLhzSx+FCbEm5JYWZValB9fVJqTWnyIUZqD RUmcd+au9yFCAumJJanZqakFqUUwWSYOTqkGxrjoOJuZma7ahy29+U5tK3OdF/NEdLfdp6UW n05LFhTuuWNhu5VN19/nXYr9wrwztXPXHt71InbyMa1glcr1v5b6pApbzXu08Nu2J82TTx2y WxG3UEzmZNakgh/fuVKZl+8+76Dj+t/J6unDs0v8Pr/SsSo5fK5/6d7z3md1qjTtvlruzHqb WKzEUpyRaKjFXFScCAAwMzQyMgIAAA== 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 --- 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)