All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: release anon file in failure path of vm creation
@ 2016-07-12  9:38 Liu Shuo
  2016-07-12 10:24 ` Paolo Bonzini
  0 siblings, 1 reply; 9+ messages in thread
From: Liu Shuo @ 2016-07-12  9:38 UTC (permalink / raw)
  To: linux-kernel, kvm
  Cc: Zhang Yanmin, He Bo, Liu Shuo, Paolo Bonzini,
	Radim Krčmář

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>
---
 virt/kvm/kvm_main.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 48bd520..8322154 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -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>
@@ -3067,6 +3068,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;
 	}
 
-- 
1.9.4

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2016-07-15  7:04 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-12  9:38 [PATCH] KVM: release anon file in failure path of vm creation Liu Shuo
2016-07-12 10:24 ` Paolo Bonzini
2016-07-14 16:46   ` Al Viro
2016-07-14 16:56     ` Paolo Bonzini
2016-07-15  2:22     ` Liu Shuo
2016-07-15  2:26       ` Al Viro
2016-07-15  3:18         ` Liu Shuo
2016-07-15  5:09           ` Al Viro
2016-07-15  7:04             ` Liu Shuo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.