Skip to content

Commit 2be5b3f

Browse files
Liu Shuobonzini
authored andcommitted
KVM: release anon file in failure path of vm creation
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 <[email protected]> Fixes: 536a6f8 Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 2f1fe81 commit 2be5b3f

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

virt/kvm/kvm_main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
#include <linux/slab.h>
5050
#include <linux/sort.h>
5151
#include <linux/bsearch.h>
52+
#include <linux/syscalls.h>
5253

5354
#include <asm/processor.h>
5455
#include <asm/io.h>
@@ -3069,6 +3070,7 @@ static int kvm_dev_ioctl_create_vm(unsigned long type)
30693070

30703071
if (kvm_create_vm_debugfs(kvm, r) < 0) {
30713072
kvm_put_kvm(kvm);
3073+
sys_close(r);
30723074
return -ENOMEM;
30733075
}
30743076

0 commit comments

Comments
 (0)