diff options
author | Nicholas Mc Guire <hofrat@osadl.org> | 2018-07-12 11:28:24 +0200 |
---|---|---|
committer | Wei Xu <xuwei5@hisilicon.com> | 2018-07-16 17:36:50 +0100 |
commit | d396cb185c0337aae5664b250cdd9a73f6eb1503 (patch) | |
tree | c4ba53db1f20d673c52734a6fa7fa99b3a1c0f11 /arch/arm/mach-hisi | |
parent | 81646a3d39ef14749301374a3a0b8311384cd412 (diff) | |
download | blackbird-obmc-linux-d396cb185c0337aae5664b250cdd9a73f6eb1503.tar.gz blackbird-obmc-linux-d396cb185c0337aae5664b250cdd9a73f6eb1503.zip |
ARM: hisi: handle of_iomap and fix missing of_node_put
Relying on an unchecked of_iomap() which can return NULL is problematic
here, an explicit check seems mandatory. Also the call to
of_find_compatible_node() returns a device node with refcount incremented
therefor an explicit of_node_put() is needed here.
Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
Fixes: commit 22bae4290457 ("ARM: hi3xxx: add hotplug support")
Signed-off-by: Wei Xu <xuwei5@hisilicon.com>
Diffstat (limited to 'arch/arm/mach-hisi')
-rw-r--r-- | arch/arm/mach-hisi/hotplug.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/arch/arm/mach-hisi/hotplug.c b/arch/arm/mach-hisi/hotplug.c index ae5461cfb67f..909bb2493781 100644 --- a/arch/arm/mach-hisi/hotplug.c +++ b/arch/arm/mach-hisi/hotplug.c @@ -148,13 +148,20 @@ static int hi3xxx_hotplug_init(void) struct device_node *node; node = of_find_compatible_node(NULL, NULL, "hisilicon,sysctrl"); - if (node) { - ctrl_base = of_iomap(node, 0); - id = HI3620_CTRL; - return 0; + if (!node) { + id = ERROR_CTRL; + return -ENOENT; } - id = ERROR_CTRL; - return -ENOENT; + + ctrl_base = of_iomap(node, 0); + of_node_put(node); + if (!ctrl_base) { + id = ERROR_CTRL; + return -ENOMEM; + } + + id = HI3620_CTRL; + return 0; } void hi3xxx_set_cpu(int cpu, bool enable) |