From patchwork Wed May 13 06:54:45 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 6394391 Return-Path: X-Original-To: patchwork-linux-omap@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 191CB9F32E for ; Wed, 13 May 2015 06:56:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 432762042C for ; Wed, 13 May 2015 06:56:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4A9882038A for ; Wed, 13 May 2015 06:56:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932611AbbEMG4n (ORCPT ); Wed, 13 May 2015 02:56:43 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:42959 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753583AbbEMGzP (ORCPT ); Wed, 13 May 2015 02:55:15 -0400 Received: from eucpsbgm2.samsung.com (unknown [203.254.199.245]) by mailout2.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0NOA003DN0K1BI50@mailout2.w1.samsung.com>; Wed, 13 May 2015 07:55:13 +0100 (BST) X-AuditID: cbfec7f5-f794b6d000001495-89-5552f5516b91 Received: from eusync4.samsung.com ( [203.254.199.214]) by eucpsbgm2.samsung.com (EUCPMTA) with SMTP id 60.86.05269.155F2555; Wed, 13 May 2015 07:55:13 +0100 (BST) Received: from localhost.localdomain ([10.252.80.64]) by eusync4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0NOA00ELI0JC0J80@eusync4.samsung.com>; Wed, 13 May 2015 07:55:13 +0100 (BST) From: Krzysztof Kozlowski To: Tero Kristo , Mike Turquette , Stephen Boyd , linux-omap@vger.kernel.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Krzysztof Kozlowski Subject: [RFT PATCH 6/8] clk: ti: clk-43xx: Prevent possible ERR_PTR dereference Date: Wed, 13 May 2015 15:54:45 +0900 Message-id: <1431500087-2275-7-git-send-email-k.kozlowski@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1431500087-2275-1-git-send-email-k.kozlowski@samsung.com> References: <1431500087-2275-1-git-send-email-k.kozlowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprELMWRmVeSWpSXmKPExsVy+t/xa7qBX4NCDXaeYrJ4/cLQ4mPPPVaL y7vmsFnMXtLPYvF0wkU2ix9nulksljztYHNg97jc18vkcefaHjaPvi2rGD2O39jO5PF5k1wA axSXTUpqTmZZapG+XQJXRs/xM0wFc3gr7ixeyd7A+I2ri5GTQ0LARGL1lz3MELaYxIV769m6 GLk4hASWMkoc2t7MDOH8Z5TY/7qZCaSKTcBYYvPyJWBVIgLHGSVW7OlnB0kwCxhK/Hz3B8wW FgiQ+P/rGhuIzSKgKnF86n6wFbwCbhKtJ55CrZOTOHlsMmsXIwcHp4C7xKV5YiCmEFDJvoa6 CYy8CxgZVjGKppYmFxQnpeca6RUn5haX5qXrJefnbmKEhNTXHYxLj1kdYhTgYFTi4Z3xNjBU iDWxrLgy9xCjBAezkgjv0ndBoUK8KYmVValF+fFFpTmpxYcYpTlYlMR5Z+56HyIkkJ5Ykpqd mlqQWgSTZeLglGpgFO9wETpy5vy7aFeNAuUPOfL9NibWFw99TvTZZ3PmwhrFJ+crepXzFqy7 c3Z60Tc9K0n7OL+uBfr+kxj2v9eLCm2TNdnB79fbuFlwyuSTgraHpwU8yLqZYrTg3oTa9ddM Ziqf1nHok1z6fLrc8bexjj9XmGzS4Gtle9J9h+eQ0Ye1nx25FcyTlFiKMxINtZiLihMBWtqg GCUCAAA= Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_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 The return value of clk_get_sys() was immediately used in clk_set_parent() and clk_set_rate(). The first one may return ERR_PTR and the latter only checks if supplied argument is non-NULL. Signed-off-by: Krzysztof Kozlowski --- drivers/clk/ti/clk-44xx.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/clk/ti/clk-44xx.c b/drivers/clk/ti/clk-44xx.c index 581db7711f51..6b045ed31747 100644 --- a/drivers/clk/ti/clk-44xx.c +++ b/drivers/clk/ti/clk-44xx.c @@ -281,9 +281,11 @@ int __init omap4xxx_dt_clk_init(void) * domain can transition to retention state when not in use. */ usb_dpll = clk_get_sys(NULL, "dpll_usb_ck"); - rc = clk_set_rate(usb_dpll, OMAP4_DPLL_USB_DEFFREQ); - if (rc) - pr_err("%s: failed to configure USB DPLL!\n", __func__); + if (!IS_ERR(usb_dpll)) { + rc = clk_set_rate(usb_dpll, OMAP4_DPLL_USB_DEFFREQ); + if (rc) + pr_err("%s: failed to configure USB DPLL!\n", __func__); + } /* * On OMAP4460 the ABE DPLL fails to turn on if in idle low-power @@ -293,9 +295,15 @@ int __init omap4xxx_dt_clk_init(void) */ abe_dpll_ref = clk_get_sys(NULL, "abe_dpll_refclk_mux_ck"); sys_32k_ck = clk_get_sys(NULL, "sys_32k_ck"); + if (IS_ERR(abe_dpll_ref) || IS_ERR(sys_32k_ck)) { + pr_err("%s: failed to configure ABE DPLL!\n", __func__); + return 0; + } + rc = clk_set_parent(abe_dpll_ref, sys_32k_ck); + abe_dpll = clk_get_sys(NULL, "dpll_abe_ck"); - if (!rc) + if (!rc && !IS_ERR(abe_dpll)) rc = clk_set_rate(abe_dpll, OMAP4_DPLL_ABE_DEFFREQ); if (rc) pr_err("%s: failed to configure ABE DPLL!\n", __func__);