From patchwork Fri Mar 27 10:43:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 6104961 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 38413BF90F for ; Fri, 27 Mar 2015 10:47:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5ED30203A4 for ; Fri, 27 Mar 2015 10:47:07 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 787D8203B7 for ; Fri, 27 Mar 2015 10:47:06 +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 1YbRkq-00067Q-53; Fri, 27 Mar 2015 10:44:44 +0000 Received: from mailout3.w1.samsung.com ([210.118.77.13]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YbRkb-0005px-ER for linux-arm-kernel@lists.infradead.org; Fri, 27 Mar 2015 10:44:30 +0000 Received: from eucpsbgm1.samsung.com (unknown [203.254.199.244]) by mailout3.w1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NLV00EDBA08FI40@mailout3.w1.samsung.com> for linux-arm-kernel@lists.infradead.org; Fri, 27 Mar 2015 10:48:08 +0000 (GMT) X-AuditID: cbfec7f4-b7f126d000001e9a-fa-551533cbd3f1 Received: from eusync2.samsung.com ( [203.254.199.212]) by eucpsbgm1.samsung.com (EUCPMTA) with SMTP id 99.E9.07834.BC335155; Fri, 27 Mar 2015 10:41:15 +0000 (GMT) Received: from AMDC1943.digital.local ([106.116.151.171]) by eusync2.samsung.com (Oracle Communications Messaging Server 7u4-23.01(7.0.4.23.0) 64bit (built Aug 10 2011)) with ESMTPA id <0NLV00AVR9TCWG50@eusync2.samsung.com>; Fri, 27 Mar 2015 10:44:04 +0000 (GMT) From: Krzysztof Kozlowski To: Kukjin Kim , linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RESEND PATCH 2/2] ARM: EXYNOS: Handle of_find_device_by_node and kstrdup failures Date: Fri, 27 Mar 2015 11:43:56 +0100 Message-id: <1427453036-6808-2-git-send-email-k.kozlowski@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1427453036-6808-1-git-send-email-k.kozlowski@samsung.com> References: <1427453036-6808-1-git-send-email-k.kozlowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrLJMWRmVeSWpSXmKPExsVy+t/xK7qnjUVDDd5/N7P4O+kYu8XrF4YW /Y9fM1tsenyN1eLyrjlsFjPO72OyWHvkLrvFqeuf2Rw4PH7/msTosWlVJ5vH5iX1HldONLF6 9G1ZxejxeZNcAFsUl01Kak5mWWqRvl0CV8b2BztYC/5yVaz5s4i1gfETRxcjJ4eEgInEk4al 7BC2mMSFe+vZQGwhgaWMEn0rgrsYuYDsPiaJ15ffsoAk2ASMJTYvX8IGkhAR6GKUmLXlN1gH s8AiRoklF51BbGGBWIn3xzYCTeXgYBFQlVj1mx8kzCvgJvF503w2iGVyEiePTWYFsTkF3CW2 TlvDCrHYTaJpziXmCYy8CxgZVjGKppYmFxQnpeca6hUn5haX5qXrJefnbmKEBNmXHYyLj1kd YhTgYFTi4TU4KBwqxJpYVlyZe4hRgoNZSYR35WORUCHelMTKqtSi/Pii0pzU4kOMTBycUg2M 5kHMed9e/eni/vb73cO16xsOs8YLsN1TvPtCsejG9hk8t/dM/mRU7TlRb9Fd/eNrI47OfPRT 1vukdTfHS/d3uU55v2/6dO69wzf3Zfql8r/PHogflT79c/rDFtetor0m5/rO5pXdeN1k6f9A UkN97/ebV6z6y75+OvbfXktsS8Mn3tsl+z2jNyqxFGckGmoxFxUnAgCzLDmQEAIAAA== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150327_034429_670106_2303B943 X-CRM114-Status: UNSURE ( 8.40 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -5.0 (-----) Cc: Olof Johansson , Krzysztof Kozlowski , Arnd Bergmann , Marek Szyprowski X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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, 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 Prevent possible NULL pointer dereference of pointer returned by of_find_device_by_node(). Handle this by skipping such power domain. Additionally fail the init on kstrdup() failure. Such case is actually not fatal because the name for power domain allocated by kstrdup() is used only in printk. Still as a precaution handle this as an error condition. Signed-off-by: Krzysztof Kozlowski --- arch/arm/mach-exynos/pm_domains.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/arch/arm/mach-exynos/pm_domains.c b/arch/arm/mach-exynos/pm_domains.c index 2c5c206f3ea9..b20d228566b9 100644 --- a/arch/arm/mach-exynos/pm_domains.c +++ b/arch/arm/mach-exynos/pm_domains.c @@ -126,6 +126,12 @@ static __init int exynos4_pm_init_power_domain(void) struct device *dev; pdev = of_find_device_by_node(np); + if (!pdev) { + pr_err("%s: failed to find device for node %s\n", + __func__, np->name); + of_node_put(np); + continue; + } dev = &pdev->dev; pd = kzalloc(sizeof(*pd), GFP_KERNEL); @@ -136,6 +142,12 @@ static __init int exynos4_pm_init_power_domain(void) } pd->pd.name = kstrdup(dev_name(dev), GFP_KERNEL); + if (!pd->pd.name) { + kfree(pd); + of_node_put(np); + return -ENOMEM; + } + pd->name = pd->pd.name; pd->base = of_iomap(np, 0); if (!pd->base) {