From: Paolo Bonzini <pbonzini@redhat.com>
To: Luiz Capitulino <lcapitulino@redhat.com>, kvm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, rkrcmar@redhat.com,
rostedt@goodmis.org, mhiramat@kernel.org, mtosatti@redhat.com
Subject: Re: [PATCH 2/4] kvm: kvm_create_vm_debugfs(): cleanup on error
Date: Fri, 2 Sep 2016 15:53:01 +0200 [thread overview]
Message-ID: <01cb23af-57b9-e595-e36b-8856d1c853f9@redhat.com> (raw)
In-Reply-To: <1472663145-1835-3-git-send-email-lcapitulino@redhat.com>
On 31/08/2016 19:05, Luiz Capitulino wrote:
> Memory and debugfs entries are leaked on error. Fix it.
>
> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
> ---
> virt/kvm/kvm_main.c | 10 +++++++---
> 1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index c1dc45e..9293285 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -585,12 +585,12 @@ static int kvm_create_vm_debugfs(struct kvm *kvm, int fd)
> sizeof(*kvm->debugfs_stat_data),
> GFP_KERNEL);
> if (!kvm->debugfs_stat_data)
> - return -ENOMEM;
> + goto out_err;
>
> for (p = debugfs_entries; p->name; p++) {
> stat_data = kzalloc(sizeof(*stat_data), GFP_KERNEL);
> if (!stat_data)
> - return -ENOMEM;
> + goto out_err;
>
> stat_data->kvm = kvm;
> stat_data->offset = p->offset;
> @@ -599,9 +599,13 @@ static int kvm_create_vm_debugfs(struct kvm *kvm, int fd)
> kvm->debugfs_dentry,
> stat_data,
> stat_fops_per_vm[p->kind]))
> - return -ENOMEM;
> + goto out_err;
> }
> return 0;
> +
> +out_err:
> + kvm_destroy_vm_debugfs(kvm);
> + return -ENOMEM;
> }
>
> static struct kvm *kvm_create_vm(unsigned long type)
>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
next prev parent reply other threads:[~2016-09-02 13:53 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-31 17:05 [PATCH 0/4] kvm: export TSC offset to user-space Luiz Capitulino
2016-08-31 17:05 ` [PATCH 1/4] kvm: kvm_destroy_vm_debugfs(): check debugs_stat_data pointer Luiz Capitulino
2016-09-02 13:51 ` Paolo Bonzini
2016-08-31 17:05 ` [PATCH 2/4] kvm: kvm_create_vm_debugfs(): cleanup on error Luiz Capitulino
2016-09-02 13:53 ` Paolo Bonzini [this message]
2016-08-31 17:05 ` [PATCH 3/4] kvm: add stub for arch specific debugfs support Luiz Capitulino
2016-09-02 13:53 ` Paolo Bonzini
2016-09-03 3:34 ` Masami Hiramatsu
2016-08-31 17:05 ` [PATCH 4/4] kvm: x86: export TSC offset to user-space Luiz Capitulino
2016-09-02 13:43 ` Stefan Hajnoczi
2016-09-02 14:15 ` Steven Rostedt
2016-09-03 0:23 ` Marcelo Tosatti
2016-09-03 4:04 ` Masami Hiramatsu
2016-09-02 16:26 ` Luiz Capitulino
2016-09-02 16:29 ` Luiz Capitulino
2016-09-02 23:49 ` Marcelo Tosatti
2016-09-03 1:29 ` Luiz Capitulino
2016-09-02 17:00 ` Paolo Bonzini
2016-09-02 17:31 ` Luiz Capitulino
2016-09-05 8:10 ` Paolo Bonzini
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=01cb23af-57b9-e595-e36b-8856d1c853f9@redhat.com \
--to=pbonzini@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=lcapitulino@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=mtosatti@redhat.com \
--cc=rkrcmar@redhat.com \
--cc=rostedt@goodmis.org \
/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