aboutsummaryrefslogtreecommitdiffstats
path: root/virt/kvm
diff options
context:
space:
mode:
authorJan Kiszka <jan.kiszka@siemens.com>2010-11-09 06:42:12 -0500
committerAvi Kivity <avi@redhat.com>2011-01-12 04:29:05 -0500
commit57e7fbee1dbd72949425b19d28415d2ddffe04ca (patch)
tree106193051d37d7b0ad9b76b495c58bdc03544322 /virt/kvm
parent30bd0c4c6c5aecc338ebf32e3a6e01c98f0a0b43 (diff)
KVM: Refactor srcu struct release on early errors
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'virt/kvm')
-rw-r--r--virt/kvm/kvm_main.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 13cefe226e44..fce0578eab0e 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -401,23 +401,19 @@ static struct kvm *kvm_create_vm(void)
401 r = -ENOMEM; 401 r = -ENOMEM;
402 kvm->memslots = kzalloc(sizeof(struct kvm_memslots), GFP_KERNEL); 402 kvm->memslots = kzalloc(sizeof(struct kvm_memslots), GFP_KERNEL);
403 if (!kvm->memslots) 403 if (!kvm->memslots)
404 goto out_err; 404 goto out_err_nosrcu;
405 if (init_srcu_struct(&kvm->srcu)) 405 if (init_srcu_struct(&kvm->srcu))
406 goto out_err; 406 goto out_err_nosrcu;
407 for (i = 0; i < KVM_NR_BUSES; i++) { 407 for (i = 0; i < KVM_NR_BUSES; i++) {
408 kvm->buses[i] = kzalloc(sizeof(struct kvm_io_bus), 408 kvm->buses[i] = kzalloc(sizeof(struct kvm_io_bus),
409 GFP_KERNEL); 409 GFP_KERNEL);
410 if (!kvm->buses[i]) { 410 if (!kvm->buses[i])
411 cleanup_srcu_struct(&kvm->srcu);
412 goto out_err; 411 goto out_err;
413 }
414 } 412 }
415 413
416 r = kvm_init_mmu_notifier(kvm); 414 r = kvm_init_mmu_notifier(kvm);
417 if (r) { 415 if (r)
418 cleanup_srcu_struct(&kvm->srcu);
419 goto out_err; 416 goto out_err;
420 }
421 417
422 kvm->mm = current->mm; 418 kvm->mm = current->mm;
423 atomic_inc(&kvm->mm->mm_count); 419 atomic_inc(&kvm->mm->mm_count);
@@ -435,6 +431,8 @@ out:
435 return kvm; 431 return kvm;
436 432
437out_err: 433out_err:
434 cleanup_srcu_struct(&kvm->srcu);
435out_err_nosrcu:
438 hardware_disable_all(); 436 hardware_disable_all();
439out_err_nodisable: 437out_err_nodisable:
440 for (i = 0; i < KVM_NR_BUSES; i++) 438 for (i = 0; i < KVM_NR_BUSES; i++)