register_cpu() stores the reference from of_get_cpu_node() in cpu->dev.of_node, but does not release it if device_register() fails. Drop the reference on failure and clear the pointer, since architecture code such as PPC's register_cpu_online() checks it for NULL before obtaining a node reference. Fixes: f86e4718f24b ("driver/core: cpu: initialize of_node in cpu's device struture") Cc: stable@vger.kernel.org Signed-off-by: Wentao Liang --- Changes in v2: - Clear cpu->dev.of_node after of_node_put(), as Sudeep requested. - Drop the series numbering. This is an independent fix and does not belong to a series with the other patches posted alongside it. That is a submission mistake on my side. Sorry for the delayed reply, the submission error, and the extra review work this caused. drivers/base/cpu.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c index 875abdc9942e..b50ba6a32a3a 100644 --- a/drivers/base/cpu.c +++ b/drivers/base/cpu.c @@ -431,6 +431,8 @@ int register_cpu(struct cpu *cpu, int num) error = device_register(&cpu->dev); if (error) { put_device(&cpu->dev); + of_node_put(cpu->dev.of_node); + cpu->dev.of_node = NULL; return error; } -- 2.34.1