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: 6104921 Return-Path: X-Original-To: patchwork-linux-samsung-soc@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 AB45ABF90F for ; Fri, 27 Mar 2015 10:44:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D85FE2041F for ; Fri, 27 Mar 2015 10:44:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E179B203B7 for ; Fri, 27 Mar 2015 10:44:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752348AbbC0KoI (ORCPT ); Fri, 27 Mar 2015 06:44:08 -0400 Received: from mailout3.w1.samsung.com ([210.118.77.13]:13395 "EHLO mailout3.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752091AbbC0KoH (ORCPT ); Fri, 27 Mar 2015 06:44:07 -0400 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>; 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 Cc: Arnd Bergmann , Olof Johansson , Marek Szyprowski , Krzysztof Kozlowski 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== Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@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 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) {