Skip to content

Commit

Permalink
KVM: explain missing kvm_put_kvm in case of failure
Browse files Browse the repository at this point in the history
The call to kvm_put_kvm was removed from error handling in commit
506cfba ("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 <[email protected]>
  • Loading branch information
bonzini committed Jun 27, 2017
1 parent 039c5d1 commit 525df86
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions virt/kvm/kvm_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3191,6 +3191,12 @@ static int kvm_dev_ioctl_create_vm(unsigned long type)
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);
Expand Down

0 comments on commit 525df86

Please sign in to comment.