From: Nicholas Mc Guire <hofrat@osadl.org>
To: Russell King <linux@armlinux.org.uk>
Cc: Shawn Guo <shawnguo@kernel.org>,
Sascha Hauer <s.hauer@pengutronix.de>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
Fabio Estevam <festevam@gmail.com>,
NXP Linux Team <linux-imx@nxp.com>,
Mark Brown <broonie@kernel.org>,
Linus Walleij <linus.walleij@linaro.org>,
Tony Lindgren <tony@atomide.com>,
Mike Rapoport <rppt@linux.vnet.ibm.com>,
Janusz Krzysztofik <jmkrzyszt@gmail.com>,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org,
Nicholas Mc Guire <hofrat@osadl.org>
Subject: [PATCH 1/3] ARM: hisi: fix error handling and missing of_node_put
Date: Sat, 13 Apr 2019 09:14:15 +0200 [thread overview]
Message-ID: <1555139666-948-4-git-send-email-hofrat@osadl.org> (raw)
In-Reply-To: <1555139666-948-1-git-send-email-hofrat@osadl.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 <hofrat@osadl.org>
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
next prev parent reply other threads:[~2019-04-13 7:20 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-13 7:14 [PATCH 0/4] ARM: imx legacy: cleanups Nicholas Mc Guire
2019-04-13 7:14 ` [PATCH 0/3] ARM: hisi: fix of_iomap errors Nicholas Mc Guire
2019-04-13 7:14 ` [PATCH] ARM: add missing of_node_put() Nicholas Mc Guire
2019-04-13 7:14 ` Nicholas Mc Guire [this message]
2019-04-13 7:14 ` [PATCH] ARM: imx: flag failure of of_iomap Nicholas Mc Guire
2019-04-13 7:14 ` [PATCH 1/4 RFC] ARM: imx legacy: warn on failed allocation Nicholas Mc Guire
2019-04-13 7:14 ` [PATCH] ARM: STi: at least warn if of_iomap fails Nicholas Mc Guire
2019-04-13 7:14 ` [PATCH V2] ARM: STi: warn if scu mapping fails Nicholas Mc Guire
2019-04-13 7:14 ` [PATCH] ARM: u300: add missing check for kmalloc Nicholas Mc Guire
2019-04-23 10:26 ` Linus Walleij
2019-04-13 7:14 ` [PATCH] ARM: ux500: add missing of_node_put() Nicholas Mc Guire
2019-04-15 9:52 ` Ulf Hansson
2019-04-16 11:49 ` Linus Walleij
2019-04-13 7:14 ` [PATCH 2/3] ARM: hisi: check of_iomap and fix missing of_node_put Nicholas Mc Guire
2019-04-16 16:09 ` [2/3] " Markus Elfring
2019-04-13 7:14 ` [PATCH 2/4] ARM: imx legacy: declare unsigned int rather than unsigned Nicholas Mc Guire
2019-04-13 7:14 ` [PATCH 3/3] ARM: hisi: handle of_iomap and fix missing of_node_put Nicholas Mc Guire
2019-04-13 7:14 ` [PATCH 3/4 RFC] ARM: imx legacy: wrap complex macro in () Nicholas Mc Guire
2019-04-13 7:14 ` [PATCH 4/4] ARM: imx legacy: add an SPDX license identifier Nicholas Mc Guire
2019-04-13 7:58 ` [PATCH 0/4] ARM: imx legacy: cleanups Joe Perches
-- strict thread matches above, loose matches on Subject: below --
2018-07-12 9:28 [PATCH 0/3] ARM: hisi: fix of_iomap errors Nicholas Mc Guire
2018-07-12 9:28 ` [PATCH 1/3] ARM: hisi: fix error handling and missing of_node_put Nicholas Mc Guire
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1555139666-948-4-git-send-email-hofrat@osadl.org \
--to=hofrat@osadl.org \
--cc=broonie@kernel.org \
--cc=festevam@gmail.com \
--cc=jmkrzyszt@gmail.com \
--cc=kernel@pengutronix.de \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-imx@nxp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=rppt@linux.vnet.ibm.com \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@kernel.org \
--cc=tony@atomide.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).