Blob Blame History Raw
From: Paolo Bonzini <pbonzini@redhat.com>
Date: Tue, 27 Jun 2017 15:45:09 +0200
Subject: KVM: explain missing kvm_put_kvm in case of failure
Patch-mainline: v4.13-rc1
Git-commit: 525df86145bf731af522ba9b3982c5b48078b81a
References: bsc#1077761

The call to kvm_put_kvm was removed from error handling in commit
506cfba9e726 ("KVM: don't use anon_inode_getfd() before possible
failures"), but it is _not_ a memory leak.  Reuse Al's explanation
to avoid that someone else makes the same mistake.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Acked-by: Alexander Graf <agraf@suse.de>
---
 virt/kvm/kvm_main.c |    6 ++++++
 1 file changed, 6 insertions(+)

--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -3191,6 +3191,12 @@
 		return PTR_ERR(file);
 	}
 
+	/*
+	 * Don't call kvm_put_kvm anymore at this point; file->f_op is
+	 * already set, with ->release() being kvm_vm_release().  In error
+	 * cases it will be called by the final fput(file) and will take
+	 * care of doing kvm_put_kvm(kvm).
+	 */
 	if (kvm_create_vm_debugfs(kvm, r) < 0) {
 		put_unused_fd(r);
 		fput(file);