linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: nixiaoming <nixiaoming@huawei.com>,
	agraf@suse.com, rkrcmar@redhat.com, benh@kernel.crashing.org,
	paulus@samba.org, mpe@ellerman.id.au
Cc: kvm-ppc@vger.kernel.org, kvm@vger.kernel.org,
	linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] fix memory leak on kvm_vm_ioctl_get_htab_fd
Date: Tue, 22 Aug 2017 17:51:09 +0200	[thread overview]
Message-ID: <e4c48fc6-3282-b3fe-60dd-3f4c911c6e91@redhat.com> (raw)
In-Reply-To: <20170822141820.67839-1-nixiaoming@huawei.com>

On 22/08/2017 16:18, nixiaoming wrote:
> 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 <nixiaoming@huawei.com>
> ---
>  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;
>  	}
> 

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>

      reply	other threads:[~2017-08-22 15:51 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-22 14:18 [PATCH] fix memory leak on kvm_vm_ioctl_get_htab_fd nixiaoming
2017-08-22 15:51 ` Paolo Bonzini [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e4c48fc6-3282-b3fe-60dd-3f4c911c6e91@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=agraf@suse.com \
    --cc=benh@kernel.crashing.org \
    --cc=kvm-ppc@vger.kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mpe@ellerman.id.au \
    --cc=nixiaoming@huawei.com \
    --cc=paulus@samba.org \
    --cc=rkrcmar@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).