summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWang Yufen <wangyufen@huawei.com>2022-12-14 15:46:23 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-11-20 11:06:54 +0100
commitad0370c41a19add69a5cf6cfd7bc82f3fa4f3509 (patch)
tree2ace12816e812f16df44e05ab164c41bb737ca01
parentd12372af8955f98b684d4f625d6f028045e5e319 (diff)
downloadlinux-stable-ad0370c41a19add69a5cf6cfd7bc82f3fa4f3509.tar.gz
linux-stable-ad0370c41a19add69a5cf6cfd7bc82f3fa4f3509.tar.bz2
linux-stable-ad0370c41a19add69a5cf6cfd7bc82f3fa4f3509.zip
powerpc/pseries: fix potential memory leak in init_cpu_associativity()
[ Upstream commit 95f1a128cd728a7257d78e868f1f5a145fc43736 ] 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 Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--arch/powerpc/platforms/pseries/lpar.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/arch/powerpc/platforms/pseries/lpar.c b/arch/powerpc/platforms/pseries/lpar.c
index 68f3b082245e..4a3425fb1939 100644
--- a/arch/powerpc/platforms/pseries/lpar.c
+++ b/arch/powerpc/platforms/pseries/lpar.c
@@ -523,8 +523,10 @@ static ssize_t vcpudispatch_stats_write(struct file *file, const char __user *p,
if (cmd) {
rc = init_cpu_associativity();
- if (rc)
+ if (rc) {
+ destroy_cpu_associativity();
goto out;
+ }
for_each_possible_cpu(cpu) {
disp = per_cpu_ptr(&vcpu_disp_data, cpu);