Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ARM: hisi: fix error handling and missing of_node_put

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")
Signed-off-by: Wei Xu <xuwei5@hisilicon.com>

authored by

Nicholas Mc Guire and committed by
Wei Xu
9f30b5ae ce397d21

+4 -4
+4 -4
arch/arm/mach-hisi/hotplug.c
··· 219 219 220 220 if (!ctrl_base) { 221 221 np = of_find_compatible_node(NULL, NULL, "hisilicon,hip01-sysctrl"); 222 - if (np) 223 - ctrl_base = of_iomap(np, 0); 224 - else 225 - BUG(); 222 + BUG_ON(!np); 223 + ctrl_base = of_iomap(np, 0); 224 + of_node_put(np); 225 + BUG_ON(!ctrl_base); 226 226 } 227 227 228 228 if (enable) {