KVM: release anon file in failure path of vm creation
authorLiu Shuo <shuo.a.liu@intel.com>
Tue, 12 Jul 2016 09:38:42 +0000 (17:38 +0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 14 Jul 2016 17:11:21 +0000 (19:11 +0200)
The failure of create debugfs of VM will return directly without release
the anon file. It will leak memory and file descriptors, even through
be not serious.

Signed-off-by: Liu Shuo <shuo.a.liu@intel.com>
Fixes: 536a6f88c49dd739961ffd53774775afed852c83
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
virt/kvm/kvm_main.c

index dd25346ec356b53308bf99ca140f2996b8c5a85b..cc182d9760edcce62ac3f15a176015122b35753e 100644 (file)
@@ -49,6 +49,7 @@
 #include <linux/slab.h>
 #include <linux/sort.h>
 #include <linux/bsearch.h>
+#include <linux/syscalls.h>
 
 #include <asm/processor.h>
 #include <asm/io.h>
@@ -3069,6 +3070,7 @@ static int kvm_dev_ioctl_create_vm(unsigned long type)
 
        if (kvm_create_vm_debugfs(kvm, r) < 0) {
                kvm_put_kvm(kvm);
+               sys_close(r);
                return -ENOMEM;
        }
 
This page took 0.025781 seconds and 5 git commands to generate.