lkml.org 
[lkml]   [2017]   [Jun]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v1 1/1] KVM: add missing kvm_put_kvm in case of failure
Date
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")
---
virt/kvm/kvm_main.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index f0fe9d0..257d2a8 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -3194,6 +3194,7 @@ static int kvm_dev_ioctl_create_vm(unsigned long type)
if (kvm_create_vm_debugfs(kvm, r) < 0) {
put_unused_fd(r);
fput(file);
+ kvm_put_kvm(kvm);
return -ENOMEM;
}

--
2.7.4
\
 
 \ /
  Last update: 2017-06-27 13:58    [W:0.042 / U:0.344 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site