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

powerpc/pseries: fix potential memory leak in init_cpu_associativity()

If the vcpu_associativity alloc memory successfully but the
pcpu_associativity fails to alloc memory, the vcpu_associativity
memory leaks.

Fixes: d62c8deeb6e6 ("powerpc/pseries: Provide vcpu dispatch statistics")
Signed-off-by: Wang Yufen <wangyufen@huawei.com>
Reviewed-by: "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/1671003983-10794-1-git-send-email-wangyufen@huawei.com

authored by

Wang Yufen and committed by
Michael Ellerman
95f1a128 007240d5

+3 -1
+3 -1
arch/powerpc/platforms/pseries/lpar.c
··· 526 526 527 527 if (cmd) { 528 528 rc = init_cpu_associativity(); 529 - if (rc) 529 + if (rc) { 530 + destroy_cpu_associativity(); 530 531 goto out; 532 + } 531 533 532 534 for_each_possible_cpu(cpu) { 533 535 disp = per_cpu_ptr(&vcpu_disp_data, cpu);