Message ID | 1671003983-10794-1-git-send-email-wangyufen@huawei.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 95f1a128cd728a7257d78e868f1f5a145fc43736 |
Headers | show |
Series | [v2] powerpc/pseries: fix potential memory leak in init_cpu_associativity() | expand |
Context | Check | Description |
---|---|---|
snowpatch_ozlabs/github-powerpc_ppctests | success | Successfully ran 8 jobs. |
snowpatch_ozlabs/github-powerpc_selftests | success | Successfully ran 8 jobs. |
snowpatch_ozlabs/github-powerpc_sparse | success | Successfully ran 4 jobs. |
snowpatch_ozlabs/github-powerpc_kernel_qemu | success | Successfully ran 24 jobs. |
snowpatch_ozlabs/github-powerpc_clang | success | Successfully ran 6 jobs. |
Wang Yufen wrote: > 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> > --- > arch/powerpc/platforms/pseries/lpar.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) Reviewed-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com> - Naveen
On Wed, 14 Dec 2022 15:46:23 +0800, Wang Yufen wrote: > If the vcpu_associativity alloc memory successfully but the > pcpu_associativity fails to alloc memory, the vcpu_associativity > memory leaks. > > Applied to powerpc/next. [1/1] powerpc/pseries: fix potential memory leak in init_cpu_associativity() https://git.kernel.org/powerpc/c/95f1a128cd728a7257d78e868f1f5a145fc43736 cheers
diff --git a/arch/powerpc/platforms/pseries/lpar.c b/arch/powerpc/platforms/pseries/lpar.c index 97ef649..bb24545 100644 --- a/arch/powerpc/platforms/pseries/lpar.c +++ b/arch/powerpc/platforms/pseries/lpar.c @@ -524,8 +524,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);
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> --- arch/powerpc/platforms/pseries/lpar.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)