Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751205AbdHaLGe (ORCPT ); Thu, 31 Aug 2017 07:06:34 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:5065 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750772AbdHaLGd (ORCPT ); Thu, 31 Aug 2017 07:06:33 -0400 From: nixiaoming To: , , , , , CC: , , , Subject: [PATCH] [RESEND] KVM:PPC:Book3s: fix memory leak in kvm_vm_ioctl_get_htab_fd Date: Thu, 31 Aug 2017 18:51:09 +0800 Message-ID: <20170831105109.58224-1-nixiaoming@huawei.com> X-Mailer: git-send-email 2.11.0.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.67.187.180] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020205.59A7EDB4.017A,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: ca17152b8f72eacf2dc0732e337c88f8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 835 Lines: 24 ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); but no free when anon_inode_getfd return fail so, add kfree(ctx) to fix memory leak Signed-off-by: nixiaoming Reviewed-by: Paolo Bonzini --- arch/powerpc/kvm/book3s_64_mmu_hv.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/powerpc/kvm/book3s_64_mmu_hv.c b/arch/powerpc/kvm/book3s_64_mmu_hv.c index b42812e..be3d08f 100644 --- a/arch/powerpc/kvm/book3s_64_mmu_hv.c +++ b/arch/powerpc/kvm/book3s_64_mmu_hv.c @@ -1940,6 +1940,7 @@ int kvm_vm_ioctl_get_htab_fd(struct kvm *kvm, struct kvm_get_htab_fd *ghf) rwflag = (ghf->flags & KVM_GET_HTAB_WRITE) ? O_WRONLY : O_RDONLY; ret = anon_inode_getfd("kvm-htab", &kvm_htab_fops, ctx, rwflag | O_CLOEXEC); if (ret < 0) { + kfree(ctx); kvm_put_kvm(kvm); return ret; } -- 2.11.0.1