Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2362052imm; Mon, 16 Jul 2018 06:52:18 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeDHfJD512gKokjbZ7GiMTEkCYI9CFMLGP/AM+fmmbTiSMKA9h7l7tt9MzRgft+wU4Ve2S7 X-Received: by 2002:a17:902:bc85:: with SMTP id bb5-v6mr16785719plb.229.1531749138330; Mon, 16 Jul 2018 06:52:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531749138; cv=none; d=google.com; s=arc-20160816; b=Hp030Crdi4GLpeIXtRaBzhCTa2dfEkuZWu/2TvCV/KEW8IqhpP+I/QCpJkZNnLQ8zc mhxwb4PcV2lSa7EVCZWg1flgIi2+SZUe205vibO8nl7do02bm4OGx5/xV6R2lcFCV18u I/2iQB7/As8HcDtk0VSf54k+DEm4YNNmAfJ+JbreeR8oSikQUVrU4TAkFLbfktGAI0ps C6HyWCVn+ePuW7D7uTLs0jnn2BR9Q20Afi4OlFi9p1KZaoBYALfRtlut6MPikxWnaZ/r mttxxreie+PqF4WLole9dK8fCNVVj3Eu7NBmPSqmGd1Qn8NNh7NvYJCmRfn73AutSv1Z Y+kg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=z4vLqRG0gckNnxNObm+IJ2gxej+DDn+/IWOFek8kOMU=; b=rsyTNj0K5te1Um5WFo8VA2JIWK1d7EH4BOKxJOnY8fZXNfR9lF2NWcA9DmLNRvlpgA 3sq5brstOP1M6FVTf8PaIWmLwUR2wg5ZCV+Kf3eSu2nQ9AU9tALOEcScRC4dBi6E9/Wn rAg/TbRfSfuuLU3S98EDa3OnDfhSXrtsQ2V3WsTDYwhDPQWLhktKqywZUe3U8S+/v0Pn VKM44ya4uAcsrjMMVLEXiGGx7easGex2kAKWTrpM+cpXvSbudMluui47PRY75TKT9WTX gEW+lDqKOQxFhA13Vy2yBI33XNO4jUNaZ7t6Bkcnud7ji5K4ux4FGWomE2aEMYSep7ly xr0Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o73-v6si26779519pfk.356.2018.07.16.06.52.01; Mon, 16 Jul 2018 06:52:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728202AbeGPOS6 (ORCPT + 99 others); Mon, 16 Jul 2018 10:18:58 -0400 Received: from www.osadl.org ([62.245.132.105]:33222 "EHLO www.osadl.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727464AbeGPOS6 (ORCPT ); Mon, 16 Jul 2018 10:18:58 -0400 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 Cc: Patrice Chotard , Russell King , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Nicholas Mc Guire 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-Spam-Status: No, score=-1.9 required=6.0 tests=BAYES_00 autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on www.osadl.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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") --- 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; -- 2.1.4