public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kvm: Fix NULL dereference doing kvm_create_vm()
@ 2019-11-06  8:26 Dan Carpenter
  2019-11-06  8:30 ` Christian Borntraeger
  0 siblings, 1 reply; 4+ messages in thread
From: Dan Carpenter @ 2019-11-06  8:26 UTC (permalink / raw)
  To: Paolo Bonzini, Jim Mattson
  Cc: Radim Krčmář, Junaid Shahid, kvm, kernel-janitors

If init_srcu_struct() or init_srcu_struct() fails then this function
returns ERR_PTR(0) which is NULL.  It leads to a NULL dereference in the
caller.

Fixes: 9121923c457d ("kvm: Allocate memslots and buses before calling kvm_arch_init_vm")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 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 d16d2054e937..91971811fa5f 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -675,6 +675,7 @@ static struct kvm *kvm_create_vm(unsigned long type)
 	INIT_HLIST_HEAD(&kvm->irq_ack_notifier_list);
 #endif
 
+	r = -ENOMEM;
 	if (init_srcu_struct(&kvm->srcu))
 		goto out_err_no_srcu;
 	if (init_srcu_struct(&kvm->irq_srcu))
-- 
2.20.1


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

end of thread, other threads:[~2019-11-09  4:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-11-06  8:26 [PATCH] kvm: Fix NULL dereference doing kvm_create_vm() Dan Carpenter
2019-11-06  8:30 ` Christian Borntraeger
2019-11-06  9:44   ` Paolo Bonzini
2019-11-09  4:19     ` Wanpeng Li

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