From patchwork Mon Jul 16 13:46:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Mc Guire X-Patchwork-Id: 10526849 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 27CE76020A for ; Mon, 16 Jul 2018 13:51:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1963828777 for ; Mon, 16 Jul 2018 13:51:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0DD1C28B66; Mon, 16 Jul 2018 13:51:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3125C28777 for ; Mon, 16 Jul 2018 13:51:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=dJIU+jfgNwCyLYdD4211Qr3O8iWJTulc1nhig4Mhedc=; b=XvV wn2z7iOe/m01S5ctDjhuvbOQwCpZuFapeMNt3cLAQyPNyKuWNQRGSqhqglm3g3sF8pewiKxlzPfK2 0YnzyAWPkib1xKpDyQPOt2NQ9hclXfpPxfjM0hFA3sjhp0USI7ywUceBNA35cNmQdyCaykw9seoz4 i8XWDA1FgIyW17rMwJJrrX3iJ62U5dXQbC5G4fI3VgcLAXKSD4aa2G9XHdmFmZKmqzMuLhOH1UHiL ciFkxfjHKGPCNniZjrmHAcMSIbxyQVsKaYe9MjHFZgmw5lM7TBUe2kDeEXKm6w2yyOEheRO5TqF2i 6shyvdiLJx/8qjp7R9XGEgkL2rz0VDQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1ff3uP-0005BE-QP; Mon, 16 Jul 2018 13:51:25 +0000 Received: from www.osadl.org ([62.245.132.105]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1ff3uL-00059v-Dq for linux-arm-kernel@lists.infradead.org; Mon, 16 Jul 2018 13:51:23 +0000 Received: from debian01.hofrr.at (178.115.242.59.static.drei.at [178.115.242.59] (may be forged)) by www.osadl.org (8.13.8/8.13.8/OSADL-2007092901) with ESMTP id w6GDleKf013440; Mon, 16 Jul 2018 15:47:40 +0200 From: Nicholas Mc Guire To: Srinivas Kandagatla Subject: [PATCH V2] ARM: STi: warn if scu mapping fails Date: Mon, 16 Jul 2018 15:46:49 +0200 Message-Id: <1531748809-12540-1-git-send-email-hofrat@osadl.org> X-Mailer: git-send-email 2.1.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180716_065121_778038_E79E2AC0 X-CRM114-Status: UNSURE ( 9.99 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, Nicholas Mc Guire , Patrice Chotard , linux-arm-kernel@lists.infradead.org, Russell King MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP If the device node is not found or the of_iomap() failed, calling scu_enable would not be safe and could lead to an undefined system state. So warn in both failure paths before returning. Signed-off-by: Nicholas Mc Guire Link: http://lkml.org/lkml/2018/7/16/219 Fixes: commit 65ebcc115889 ("ARM: sti: Add STiH415 SOC support") Acked-by: Patrice Chotard --- V2: replacement of WARN_ON() by a meaningful pr_err as suggested by Patrice CHOTARD . Problem was found by an experimental coccinelle script Patch was compile tested with: multi_v7_defconfig (implies CONFIG_ARCH_STI=y, CONFIG_SMP=y) (with one sparse warning unrelated to the proposed change) Patch is against 4.18-rc4 (localversion-next is next-20180716) arch/arm/mach-sti/platsmp.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/arch/arm/mach-sti/platsmp.c b/arch/arm/mach-sti/platsmp.c index 231f19e..530e9a5 100644 --- a/arch/arm/mach-sti/platsmp.c +++ b/arch/arm/mach-sti/platsmp.c @@ -107,12 +107,22 @@ static void __init sti_smp_prepare_cpus(unsigned int max_cpus) np = of_find_compatible_node(NULL, NULL, "arm,cortex-a9-scu"); - if (np) { - scu_base = of_iomap(np, 0); - scu_enable(scu_base); - of_node_put(np); + if (!np) { + pr_err("SCU not found at %s:%s():%d\n", + __FILE__, __func__, __LINE__); + return; } + scu_base = of_iomap(np, 0); + of_node_put(np); + if (!scu_base) { + pr_err("SCU remap failed at %s:%s():%d\n", + __FILE__, __func__, __LINE__); + return; + } + + scu_enable(scu_base); + if (max_cpus <= 1) return;