Commit 5fee503f authored by Peng Wu's avatar Peng Wu Committed by Huang Xiaojia
Browse files

ARM: hisi: Add missing of_node_put after of_find_compatible_node

stable inclusion
from stable-v4.19.247
commit dd4be8ecfb41a29e7c4e551b4e866157ce4a3429
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/IBP6KO
CVE: CVE-2022-49447

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=dd4be8ecfb41a29e7c4e551b4e866157ce4a3429



--------------------------------

[ Upstream commit 9bc72e47 ]

of_find_compatible_node  will increment the refcount of the returned
device_node. Calling of_node_put() to avoid the refcount leak

Signed-off-by: default avatarPeng Wu <wupeng58@huawei.com>
Signed-off-by: default avatarWei Xu <xuwei5@hisilicon.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarHuang Xiaojia <huangxiaojia2@huawei.com>
parent 55990887
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -70,14 +70,17 @@ static void __init hi3xxx_smp_prepare_cpus(unsigned int max_cpus)
		}
		ctrl_base = of_iomap(np, 0);
		if (!ctrl_base) {
			of_node_put(np);
			pr_err("failed to map address\n");
			return;
		}
		if (of_property_read_u32(np, "smp-offset", &offset) < 0) {
			of_node_put(np);
			pr_err("failed to find smp-offset property\n");
			return;
		}
		ctrl_base += offset;
		of_node_put(np);
	}
}

@@ -163,6 +166,7 @@ static int hip01_boot_secondary(unsigned int cpu, struct task_struct *idle)
	if (WARN_ON(!node))
		return -1;
	ctrl_base = of_iomap(node, 0);
	of_node_put(node);

	/* set the secondary core boot from DDR */
	remap_reg_value = readl_relaxed(ctrl_base + REG_SC_CTRL);