public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Al Viro <viro@ZenIV.linux.org.uk>
To: Claudio Imbrenda <imbrenda@linux.vnet.ibm.com>
Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
	borntraeger@de.ibm.com, frankja@linux.vnet.ibm.com,
	pbonzini@redhat.com
Subject: Re: [PATCH v1 1/1] KVM: add missing kvm_put_kvm in case of failure
Date: Tue, 27 Jun 2017 14:34:43 +0100	[thread overview]
Message-ID: <20170627133443.GF10672@ZenIV.linux.org.uk> (raw)
In-Reply-To: <1498564636-20259-1-git-send-email-imbrenda@linux.vnet.ibm.com>

On Tue, Jun 27, 2017 at 01:57:16PM +0200, Claudio Imbrenda wrote:
> If I'm not missing anything, in case kvm_create_vm_debugfs fails, we
> will have a memory leak due to not freeing the kvm object.
> 
> A call to kvm_put_kvm was accidentally removed from an error handling in
> commit 506cfba9e726 ("KVM: don't use anon_inode_getfd() before possible failures")
> 
> This patch simply restores the call to kvm_put_kvm, so that the kvm
> object is destroyed before returning an error.
> 
> Signed-off-by: Claudio Imbrenda <imbrenda@linux.vnet.ibm.com>
> Fixes: 506cfba9e726 ("KVM: don't use anon_inode_getfd() before possible failures")

What you are missing is that by that point we have file->f_op already
set, with ->release() being kvm_vm_release().  It will be called by
final fput(), and that's what will do your "missing" kvm_put_kvm().

IOW, NAK - removal was not accidental and you've just introduced
double-put there.

  parent reply	other threads:[~2017-06-27 13:34 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-27 11:57 [PATCH v1 1/1] KVM: add missing kvm_put_kvm in case of failure Claudio Imbrenda
2017-06-27 13:08 ` Paolo Bonzini
2017-06-27 13:50   ` Al Viro
2017-06-27 13:57     ` Paolo Bonzini
2017-06-27 13:34 ` Al Viro [this message]
2017-06-27 13:40   ` 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=20170627133443.GF10672@ZenIV.linux.org.uk \
    --to=viro@zeniv.linux.org.uk \
    --cc=borntraeger@de.ibm.com \
    --cc=frankja@linux.vnet.ibm.com \
    --cc=imbrenda@linux.vnet.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@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