public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: fix possible coalesced_mmio_ring page leaks.
@ 2015-02-12  4:58 Xiubo Li
  2015-02-24 16:44 ` Marcelo Tosatti
  0 siblings, 1 reply; 3+ messages in thread
From: Xiubo Li @ 2015-02-12  4:58 UTC (permalink / raw)
  To: gleb, pbonzini; +Cc: kvm, Xiubo Li

It forgets to free coalesced_mmio_ring page after the anon_inode_getfd
fails.

Signed-off-by: Xiubo Li <lixiubo@cmss.chinamobile.com>
---
 virt/kvm/kvm_main.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 8579f18..85e8106 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -2784,16 +2784,22 @@ static int kvm_dev_ioctl_create_vm(unsigned long type)
 		return PTR_ERR(kvm);
 #ifdef KVM_COALESCED_MMIO_PAGE_OFFSET
 	r = kvm_coalesced_mmio_init(kvm);
-	if (r < 0) {
-		kvm_put_kvm(kvm);
-		return r;
-	}
+	if (r < 0)
+		goto out_put_kvm;
 #endif
 	r = anon_inode_getfd("kvm-vm", &kvm_vm_fops, kvm, O_RDWR | O_CLOEXEC);
 	if (r < 0)
-		kvm_put_kvm(kvm);
+		goto out_mmio_free;
 
 	return r;
+
+out_mmio_free:
+#ifdef KVM_COALESCED_MMIO_PAGE_OFFSET
+	kvm_coalesced_mmio_free(kvm);
+#endif
+out_put_kvm:
+	kvm_put_kvm(kvm);
+	return r;
 }
 
 static long kvm_dev_ioctl(struct file *filp,
-- 
1.9.1




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

end of thread, other threads:[~2015-02-26  2:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-12  4:58 [PATCH] KVM: fix possible coalesced_mmio_ring page leaks Xiubo Li
2015-02-24 16:44 ` Marcelo Tosatti
2015-02-26  2:29   ` Xiubo Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox