Skip to contentSkip to conversation

powerpc/pseries/hotplug-cpu: remove double free in error path

PATCH Applied Nathan Lynch 2 participants 2 messages Sep 19, 2019 – Aug 2, 2020 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powerpc/pseries/hotplug-cpu: remove double free in error path

In the unlikely event that the device tree lacks a /cpus node, find_dlpar_cpus_to_add() oddly frees the cpu_drcs buffer it has been passed before returning an error. Its only caller also frees the buffer on error.

Remove the less conventional kfree() of a caller-supplied buffer from find_dlpar_cpus_to_add().

Fixes 90edf184b9b7 ("powerpc/pseries: Add CPU dlpar add functionality")
---
 arch/powerpc/platforms/pseries/hotplug-cpu.c | 1 -
 1 file changed, 1 deletion(-)
arch/powerpc/platforms/pseries/hotplug-cpu.c +0 -1
index bbda646b63b5..c743da343acb 100644
@@ -726,7 +726,6 @@ static int find_dlpar_cpus_to_add(u32 *cpu_drcs, u32 cpus_to_add)
 	parent = of_find_node_by_path("/cpus");
 	if (!parent) {
 		pr_warn("Could not find CPU root node in device tree\n");
-		kfree(cpu_drcs);
 		return -1;
 	}
 
Signature · 1 line
2.20.1
#1 lore raw
Quoted 7 lines · Nathan Lynch

In the unlikely event that the device tree lacks a /cpus node, find_dlpar_cpus_to_add() oddly frees the cpu_drcs buffer it has been passed before returning an error. Its only caller also frees the buffer on error.

Remove the less conventional kfree() of a caller-supplied buffer from find_dlpar_cpus_to_add().

Applied to powerpc/next.

[1/1] powerpc/pseries/hotplug-cpu: Remove double free in error path

      https://git.kernel.org/powerpc/c/a0ff72f9f5a780341e7ff5e9ba50a0dad5fa1980

cheers