From patchwork Fri Mar 27 12:28:24 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 6106651 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 14F669F39E for ; Fri, 27 Mar 2015 12:28:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2CDC22041B for ; Fri, 27 Mar 2015 12:28:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 282A720435 for ; Fri, 27 Mar 2015 12:28:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932217AbbC0M2j (ORCPT ); Fri, 27 Mar 2015 08:28:39 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:24466 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932198AbbC0M2g (ORCPT ); Fri, 27 Mar 2015 08:28:36 -0400 Received: from eucpsbgm1.samsung.com (unknown [203.254.199.244]) 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 <0NLV00ETOEUFOD60@mailout1.w1.samsung.com>; Fri, 27 Mar 2015 12:32:39 +0000 (GMT) X-AuditID: cbfec7f4-b7f126d000001e9a-3d-55154c48f0f6 Received: from eusync3.samsung.com ( [203.254.199.213]) by eucpsbgm1.samsung.com (EUCPMTA) with SMTP id 39.3C.07834.84C45155; Fri, 27 Mar 2015 12:25:44 +0000 (GMT) Received: from AMDC1943.digital.local ([106.116.151.171]) by eusync3.samsung.com (Oracle Communications Messaging Server 7u4-23.01(7.0.4.23.0) 64bit (built Aug 10 2011)) with ESMTPA id <0NLV00I58ENIRF00@eusync3.samsung.com>; Fri, 27 Mar 2015 12:28:33 +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: [PATCH v2 2/3] ARM: EXYNOS: Handle of_find_device_by_node and kstrdup failures Date: Fri, 27 Mar 2015 13:28:24 +0100 Message-id: <1427459305-26625-2-git-send-email-k.kozlowski@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1427459305-26625-1-git-send-email-k.kozlowski@samsung.com> References: <1427459305-26625-1-git-send-email-k.kozlowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrDJMWRmVeSWpSXmKPExsVy+t/xq7oePqKhBrP2Glr8nXSM3eL1C0OL /sevmS02Pb7GanF51xw2ixnn9zFZrD1yl93i1PXPbA4cHr9/TWL02LSqk81j85J6jysnmlg9 +rasYvT4vEkugC2KyyYlNSezLLVI3y6BK2PHr/VsBfO4Kz4+ec3WwNjJ2cXIwSEhYCLx+JF6 FyMnkCkmceHeerYuRi4OIYGljBK7TjxlgXD6mCRm/H7MDFLFJmAssXn5ErAqEYEuRolZW36z gSSYBRYxSiy56AxiCwtEShy58gCom52DRUBV4oQFSJRXwF3i+b+jbBDL5CROHpvMCmJzCnhI 3L2ylhHEFgKquTfrFvsERt4FjAyrGEVTS5MLipPScw31ihNzi0vz0vWS83M3MUJC7MsOxsXH rA4xCnAwKvHwGhwUDhViTSwrrsw9xCjBwawkwsvvIhoqxJuSWFmVWpQfX1Sak1p8iJGJg1Oq gdH1YuZmg23LJWVmGjLw+bSe2O5xcLvmZuUXZz4eEWTr4eBaPvfb483/Zpce8vrgYf863uyi +JvaPIbqyD35G4wOu8tsCkyMdX4svnSR6pyFc3eeOvNwQhrPBgNHo6pPPS03n7y6pcw5Y8uu xV/5yoy/V4g+PHZ0ucqloC0q9iuquIvTXd+zJqoosRRnJBpqMRcVJwIA7aC/kw8CAAA= 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 --- Changes since v1: None. --- 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 14622b5f4481..61c32ccc9f7a 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) {