From patchwork Wed May 13 06:54:43 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 6394301 Return-Path: X-Original-To: patchwork-linux-omap@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 69649BEEE1 for ; Wed, 13 May 2015 06:55:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8A99C20426 for ; Wed, 13 May 2015 06:55:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 640AD20437 for ; Wed, 13 May 2015 06:55:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753891AbbEMGzO (ORCPT ); Wed, 13 May 2015 02:55:14 -0400 Received: from mailout4.w1.samsung.com ([210.118.77.14]:43146 "EHLO mailout4.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753781AbbEMGzI (ORCPT ); Wed, 13 May 2015 02:55:08 -0400 Received: from eucpsbgm2.samsung.com (unknown [203.254.199.245]) by mailout4.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0NOA008D00JUQ650@mailout4.w1.samsung.com>; Wed, 13 May 2015 07:55:06 +0100 (BST) X-AuditID: cbfec7f5-f794b6d000001495-73-5552f54adcab Received: from eusync4.samsung.com ( [203.254.199.214]) by eucpsbgm2.samsung.com (EUCPMTA) with SMTP id CC.76.05269.A45F2555; Wed, 13 May 2015 07:55:06 +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:06 +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 4/8] clk: ti: clk-33xx: Prevent possible ERR_PTR dereference Date: Wed, 13 May 2015 15:54:43 +0900 Message-id: <1431500087-2275-5-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/xa7peX4NCDeZcELB4/cLQ4mPPPVaL y7vmsFnMXtLPYvF0wkU2ix9nulksljztYHNg97jc18vkcefaHjaPvi2rGD2O39jO5PF5k1wA axSXTUpqTmZZapG+XQJXxtrP3YwFx7kqZsz+z9LAeI+ji5GTQ0LARKLp3GpWCFtM4sK99Wxd jFwcQgJLGSUubT/OCuH8Z5T4uvAoC0gVm4CxxOblS8CqRASOM0qs2NPPDpJgFjCU+PnuD5gt LBAgMX/CbrAGFgFViU8v5oPFeQXcJD5P2sAMsU5O4uSxyUAbODg4BdwlLs0TAzGFgEr2NdRN YORdwMiwilE0tTS5oDgpPddIrzgxt7g0L10vOT93EyMkpL7uYFx6zOoQowAHoxIP74y3gaFC rIllxZW5hxglOJiVRHiXvgsKFeJNSaysSi3Kjy8qzUktPsQozcGiJM47c9f7ECGB9MSS1OzU 1ILUIpgsEwenVAPjkm7BVtHmRKmG3Xb/7Jwm5boz95bNOfC8S3zdJZdYye7GsEzjRvcUKYkJ f6NWycbs9FZVLBTxVfJgu/BUKPPqc+f45bqXIvJmHtq36+vaG7yOe5KqCxvlWff59Z10V/ez qdqjOUU/i+1Bb4FdRTBv3nSvnSF5cl3+Kb5+aZua7PcbMZpdV2Ipzkg01GIuKk4EADgROAMl AgAA 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(). 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-33xx.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/clk/ti/clk-33xx.c b/drivers/clk/ti/clk-33xx.c index 028b33783d38..c08db8944fb8 100644 --- a/drivers/clk/ti/clk-33xx.c +++ b/drivers/clk/ti/clk-33xx.c @@ -141,10 +141,12 @@ int __init am33xx_dt_clk_init(void) clk1 = clk_get_sys(NULL, "sys_clkin_ck"); clk2 = clk_get_sys(NULL, "timer3_fck"); - clk_set_parent(clk2, clk1); + if (!IS_ERR(clk1) && !IS_ERR(clk2)) + clk_set_parent(clk2, clk1); clk2 = clk_get_sys(NULL, "timer6_fck"); - clk_set_parent(clk2, clk1); + if (!IS_ERR(clk1) && !IS_ERR(clk2)) + clk_set_parent(clk2, clk1); /* * The On-Chip 32K RC Osc clock is not an accurate clock-source as per * the design/spec, so as a result, for example, timer which supposed @@ -154,7 +156,8 @@ int __init am33xx_dt_clk_init(void) */ clk1 = clk_get_sys(NULL, "wdt1_fck"); clk2 = clk_get_sys(NULL, "clkdiv32k_ick"); - clk_set_parent(clk1, clk2); + if (!IS_ERR(clk1) && !IS_ERR(clk2)) + clk_set_parent(clk1, clk2); return 0; }