Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp279641yba; Sat, 13 Apr 2019 00:23:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqzHcOlSOBDrGdDyyylV5bAuWLO6F+lXIoIYyFOGA1Fc6p02RoI82HQ6Z2dNgoGobi+yJIja X-Received: by 2002:a17:902:7c8c:: with SMTP id y12mr61841292pll.209.1555140192676; Sat, 13 Apr 2019 00:23:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555140192; cv=none; d=google.com; s=arc-20160816; b=0W7qN/iCWk2ZuYnwuNUlbXauETyY9DBQFvLj8KfDUYRel5zz2YNU47YBxF/f1FM6N1 XG/WZPr1tdWil9W9RzXqCPL1QxMPb7wNK/B331qCOSQjY2b0xk/APyTxPTcI5f8k3uAd vjKubUENbWhi5NTvhJ8mNbXh3r0zMAB9j6/2FqXWvL74xQ1dh3eeAckFQKRhSXG51M0n B1Z168ug927ZyiPDFqQqAFpHIQ49y0thlgY5ZWGcGo6HC1NR4rbi6HuEpGpj5HfFNUFD OqMLEdlCZo5z2Q859+WQcKGewz5SxGU4BC5VDYy+j9CKe3m1kVelVth1nE7IESuz9zm7 wSyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=z4vLqRG0gckNnxNObm+IJ2gxej+DDn+/IWOFek8kOMU=; b=zMavp0/5Ed1m5ejJmtwYfOiDO/ztAaarMiNA/DJ9nGiwRrkDLR220D5Kfqxo11oFnd zU5GCOa3cSjxyZs4ClrugB2OfYuJazofZoYdr2Ziak2QNCdWb42aRS6v5rUr0yDU2avI wQdHxTsKTJWtRBWcyfhkVruW5Kpe3RwT9PlJYsPmM1K68hJa2GTBBcDkFxqLW5ehYYDa CzwDVh7Pz1AGLi6IF0vTphJm3kw4EygNPlmTACqNq8YFcVQF+OkEAoI1qn+Rzt1U1fu7 Ca36D5ulTjJqDHmxHivHdQlACpghznRGtlW0OBs4RRsoAqTkpgjETjLZwJhH9vlxInNP Yjkg== 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 76si40109887pge.555.2019.04.13.00.22.56; Sat, 13 Apr 2019 00:23:12 -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 S1727445AbfDMHVw (ORCPT + 99 others); Sat, 13 Apr 2019 03:21:52 -0400 Received: from www.osadl.org ([62.245.132.105]:36459 "EHLO www.osadl.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727398AbfDMHVu (ORCPT ); Sat, 13 Apr 2019 03:21:50 -0400 Received: from debian01.hofrr.at (178.115.242.59.static.drei.at [178.115.242.59]) by www.osadl.org (8.13.8/8.13.8/OSADL-2007092901) with ESMTP id x3D7JfAV003435; Sat, 13 Apr 2019 09:20:19 +0200 From: Nicholas Mc Guire To: Russell King Cc: Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Mark Brown , Linus Walleij , Tony Lindgren , Mike Rapoport , Janusz Krzysztofik , 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: Sat, 13 Apr 2019 09:14:19 +0200 Message-Id: <1555139666-948-8-git-send-email-hofrat@osadl.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1555139666-948-1-git-send-email-hofrat@osadl.org> References: <1555139666-948-1-git-send-email-hofrat@osadl.org> X-Spam-Status: No, score=-1.9 required=6.0 tests=BAYES_00,DATE_IN_FUTURE_96_Q, RCVD_IN_DNSWL_MED 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