Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1675709

Re: [PATCH v1 1/1] KVM: add missing kvm_put_kvm in case of failure

From Al Viro <viro@ZenIV.linux.org.uk>
Newsgroups linux.kernel
Subject Re: [PATCH v1 1/1] KVM: add missing kvm_put_kvm in case of failure
Date 2017-06-27 15:40 +0200
Message-ID <tWYSL-18m-29@gated-at.bofh.it> (permalink)
References <tWXjX-8qo-13@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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.

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v1 1/1] KVM: add missing kvm_put_kvm in case of failure Claudio Imbrenda <imbrenda@linux.vnet.ibm.com> - 2017-06-27 14:00 +0200
  Re: [PATCH v1 1/1] KVM: add missing kvm_put_kvm in case of failure Paolo Bonzini <pbonzini@redhat.com> - 2017-06-27 15:10 +0200
    Re: [PATCH v1 1/1] KVM: add missing kvm_put_kvm in case of failure Paolo Bonzini <pbonzini@redhat.com> - 2017-06-27 16:00 +0200
    Re: [PATCH v1 1/1] KVM: add missing kvm_put_kvm in case of failure Al Viro <viro@ZenIV.linux.org.uk> - 2017-06-27 16:00 +0200
  Re: [PATCH v1 1/1] KVM: add missing kvm_put_kvm in case of failure Al Viro <viro@ZenIV.linux.org.uk> - 2017-06-27 15:40 +0200
    Re: [PATCH v1 1/1] KVM: add missing kvm_put_kvm in case of failure Paolo Bonzini <pbonzini@redhat.com> - 2017-06-27 15:50 +0200

csiph-web