From patchwork Tue Feb 3 17:28:49 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 5770241 Return-Path: X-Original-To: patchwork-linux-samsung-soc@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 9A35D9F302 for ; Tue, 3 Feb 2015 17:29:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8F939201B4 for ; Tue, 3 Feb 2015 17:29:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 94374201BB for ; Tue, 3 Feb 2015 17:28:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756108AbbBCR26 (ORCPT ); Tue, 3 Feb 2015 12:28:58 -0500 Received: from mailout1.w1.samsung.com ([210.118.77.11]:51926 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751686AbbBCR25 (ORCPT ); Tue, 3 Feb 2015 12:28:57 -0500 Received: from eucpsbgm2.samsung.com (unknown [203.254.199.245]) by mailout1.w1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NJ700IQ3I32XU50@mailout1.w1.samsung.com>; Tue, 03 Feb 2015 17:33:02 +0000 (GMT) X-AuditID: cbfec7f5-b7fc86d0000066b7-f0-54d104c5a123 Received: from eusync1.samsung.com ( [203.254.199.211]) by eucpsbgm2.samsung.com (EUCPMTA) with SMTP id 82.0D.26295.5C401D45; Tue, 03 Feb 2015 17:26:29 +0000 (GMT) Received: from AMDC1943.digital.local ([106.116.151.171]) by eusync1.samsung.com (Oracle Communications Messaging Server 7u4-23.01(7.0.4.23.0) 64bit (built Aug 10 2011)) with ESMTPA id <0NJ700LSZHW3QB90@eusync1.samsung.com>; Tue, 03 Feb 2015 17:28:55 +0000 (GMT) From: Krzysztof Kozlowski To: Russell King , Kukjin Kim , linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Kyungmin Park , Bartlomiej Zolnierkiewicz , Marek Szyprowski , Krzysztof Kozlowski Subject: [PATCH] ARM: EXYNOS: Handle of_find_device_by_node and kstrdup failures Date: Tue, 03 Feb 2015 18:28:49 +0100 Message-id: <1422984529-17729-1-git-send-email-k.kozlowski@samsung.com> X-Mailer: git-send-email 1.9.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrGJMWRmVeSWpSXmKPExsVy+t/xy7pHWS6GGExcw2KxccZ6VovXLwwt +h+/ZrY42/SG3WLT42usFpd3zWGzmHF+H5PF7cu8FmuP3GV34PRoae5h89i0qpPNY/OSeo++ LasYPT5vkgtgjeKySUnNySxLLdK3S+DK+LJiH0vBD66K43/6WBoY33J0MXJySAiYSGzZfIIF whaTuHBvPVsXIxeHkMBSRokdXd1MIAkhgT4mibnr00FsNgFjic3Ll4AViQhsZpTob9zNCuIw CxxllLgx6y5Yh7BAgMSJm1MYQWwWAVWJO292gtm8Au4Sc6ZcZoRYJydx8thk1gmM3AsYGVYx iqaWJhcUJ6XnGukVJ+YWl+al6yXn525ihITN1x2MS49ZHWIU4GBU4uHVeHchRIg1say4MvcQ owQHs5II757fQCHelMTKqtSi/Pii0pzU4kOMTBycUg2MkzP85/P8ijpWdPJk/yEXG/XVypPT fjfnb+24X66i2RX7k0klr9dV8IPvrdduFefZJOMkDplt/TA9i8U0ftHvE79iN8/5ald12abo lJrjLYfIAwKFCUWcT3Jt19jytfktP2O/au7Vv21KX6471D277/ttc9GWa09Yzwbf62S4pDR9 w9+ei8sWKLEUZyQaajEXFScCAO6nlT75AQAA 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 fd7640a6b503..4c6c29ba58ef 100644 --- a/arch/arm/mach-exynos/pm_domains.c +++ b/arch/arm/mach-exynos/pm_domains.c @@ -116,6 +116,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); @@ -126,6 +132,12 @@ static __init int exynos4_pm_init_power_domain(void) } pd->pd.name = kstrdup(np->name, 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) {