aboutsummaryrefslogtreecommitdiffstats
path: root/virt
diff options
context:
space:
mode:
Diffstat (limited to 'virt')
-rw-r--r--virt/kvm/kvm_main.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index d9cfb782cb81..4c5b9a239674 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -775,10 +775,10 @@ skip_lpage:
775 775
776 if (!npages) { 776 if (!npages) {
777 r = -ENOMEM; 777 r = -ENOMEM;
778 slots = kzalloc(sizeof(struct kvm_memslots), GFP_KERNEL); 778 slots = kmemdup(kvm->memslots, sizeof(struct kvm_memslots),
779 GFP_KERNEL);
779 if (!slots) 780 if (!slots)
780 goto out_free; 781 goto out_free;
781 memcpy(slots, kvm->memslots, sizeof(struct kvm_memslots));
782 if (mem->slot >= slots->nmemslots) 782 if (mem->slot >= slots->nmemslots)
783 slots->nmemslots = mem->slot + 1; 783 slots->nmemslots = mem->slot + 1;
784 slots->generation++; 784 slots->generation++;
@@ -810,10 +810,10 @@ skip_lpage:
810 } 810 }
811 811
812 r = -ENOMEM; 812 r = -ENOMEM;
813 slots = kzalloc(sizeof(struct kvm_memslots), GFP_KERNEL); 813 slots = kmemdup(kvm->memslots, sizeof(struct kvm_memslots),
814 GFP_KERNEL);
814 if (!slots) 815 if (!slots)
815 goto out_free; 816 goto out_free;
816 memcpy(slots, kvm->memslots, sizeof(struct kvm_memslots));
817 if (mem->slot >= slots->nmemslots) 817 if (mem->slot >= slots->nmemslots)
818 slots->nmemslots = mem->slot + 1; 818 slots->nmemslots = mem->slot + 1;
819 slots->generation++; 819 slots->generation++;
@@ -2520,10 +2520,9 @@ int kvm_io_bus_register_dev(struct kvm *kvm, enum kvm_bus bus_idx, gpa_t addr,
2520 if (bus->dev_count > NR_IOBUS_DEVS-1) 2520 if (bus->dev_count > NR_IOBUS_DEVS-1)
2521 return -ENOSPC; 2521 return -ENOSPC;
2522 2522
2523 new_bus = kzalloc(sizeof(struct kvm_io_bus), GFP_KERNEL); 2523 new_bus = kmemdup(bus, sizeof(struct kvm_io_bus), GFP_KERNEL);
2524 if (!new_bus) 2524 if (!new_bus)
2525 return -ENOMEM; 2525 return -ENOMEM;
2526 memcpy(new_bus, bus, sizeof(struct kvm_io_bus));
2527 kvm_io_bus_insert_dev(new_bus, dev, addr, len); 2526 kvm_io_bus_insert_dev(new_bus, dev, addr, len);
2528 rcu_assign_pointer(kvm->buses[bus_idx], new_bus); 2527 rcu_assign_pointer(kvm->buses[bus_idx], new_bus);
2529 synchronize_srcu_expedited(&kvm->srcu); 2528 synchronize_srcu_expedited(&kvm->srcu);