Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1478011imm; Thu, 12 Jul 2018 02:34:50 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfVQXp/KwA6tQW12+OKaKly1iycqG77rv/rM2wTRg+ztnQgxiEt5td2lhPWZziNqGHGVhlB X-Received: by 2002:a65:6411:: with SMTP id a17-v6mr1367216pgv.287.1531388090270; Thu, 12 Jul 2018 02:34:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531388090; cv=none; d=google.com; s=arc-20160816; b=fsmMmJpTQMlvnbTIa9Qpi73YvfP6Yv3eGIMlEfx24XF9aI0KDEo8NRUGAob71LOBWG ryfkT2in3POh49lW7WaAA84aH/P6sItNfzHSWipmH7DX4MUCADytNcSsOgbGppelxGFj jaLTRmwQ7ExYnydmv+xh8BaaYNG7hJ/12aI2lmeF98g4Wm1UM1iyV0CTYQ0/Xz57u2f5 TY88EW2VELcqyNJMR95uyfdjS11acbjTYKi/cAQZ6zjFYSbm7hUamWfd+LAo1fK189jA /CbPOxCgL2m4+csGL+Esta8teDwzMugnmuoEnUA3LPLsxoFx06Iz+jicSmSJiav1CcsQ 5L2w== 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:arc-authentication-results; bh=MHGABP5IAgyIX7oUUNjK/DbS+D0+LCOAgruBQVpPFtk=; b=vogtGPYVFYWIsbJ3RlMwqRI6dmyQZTShHpwJZVTAXJ07XBgy0Veu24c88MzbChO9PO 0pA7qPtdDMxUIyquJrQe9qRHrYgZUUSgy6rOW4JvvPc4bYSOsqTfKP9Uq96ZyHmGqw3l ClDmO0Bm0wv53R389BGYP4j7NzOb4pw2bK1MpU4ErsquW/GdLFvzr1x0ba8vnIiPN9zD i1lLjH3xhxZQfXGfG4DxzSXjszncv/rqxkmtJzT6jxMEtqKm/CJ3cbuNMTmNZMzsHnz5 CwTVCdYDTaayrUC2AXURFHoKqPBKakLsfak/lYOWEJISiFjeL+JQ4VTwQAKvU/d4SZGD vUnA== 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 s2-v6si5570816plp.259.2018.07.12.02.34.34; Thu, 12 Jul 2018 02:34:50 -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 S1726713AbeGLJmi (ORCPT + 99 others); Thu, 12 Jul 2018 05:42:38 -0400 Received: from www.osadl.org ([62.245.132.105]:60885 "EHLO www.osadl.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726532AbeGLJmi (ORCPT ); Thu, 12 Jul 2018 05:42:38 -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 w6C9T86K021688; Thu, 12 Jul 2018 11:29:14 +0200 From: Nicholas Mc Guire To: Wei Xu Cc: Wang Long , Haifeng Yan , Russell King , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Nicholas Mc Guire Subject: [PATCH 1/3] ARM: hisi: fix error handling and missing of_node_put Date: Thu, 12 Jul 2018 11:28:22 +0200 Message-Id: <1531387704-13265-2-git-send-email-hofrat@osadl.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1531387704-13265-1-git-send-email-hofrat@osadl.org> References: <1531387704-13265-1-git-send-email-hofrat@osadl.org> X-Spam-Status: No, score=0.4 required=6.0 tests=BAYES_00,DATE_IN_FUTURE_96_Q autolearn=no 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 of_iomap() can return NULL which seems critical here and thus should be explicitly flagged so that the cause of system halting can be understood. As of_find_compatible_node() is returning a device node with refcount incremented it must be explicitly decremented here. Signed-off-by: Nicholas Mc Guire Fixes: commit 7fda91e73155 ("ARM: hisi: enable smp for HiP01") --- Problem located by experimental coccinelle script Patch was compile tested with: hisi_defconfig (implies CONFIG_SMP=y) There are two change related checkpatch warnings about "WARNING: Avoid crashing the kernel - try using WARN_ON" but here the BUG_ON() seems adequate. Patch is against 4.18-rc3 (localversion-next is next-20180712) arch/arm/mach-hisi/hotplug.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/arm/mach-hisi/hotplug.c b/arch/arm/mach-hisi/hotplug.c index a129aae..3b0d1c6 100644 --- a/arch/arm/mach-hisi/hotplug.c +++ b/arch/arm/mach-hisi/hotplug.c @@ -219,10 +219,10 @@ void hip01_set_cpu(int cpu, bool enable) if (!ctrl_base) { np = of_find_compatible_node(NULL, NULL, "hisilicon,hip01-sysctrl"); - if (np) - ctrl_base = of_iomap(np, 0); - else - BUG(); + BUG_ON(!np); + ctrl_base = of_iomap(np, 0); + of_node_put(np); + BUG_ON(!ctrl_base); } if (enable) { -- 2.1.4