diff options
author | Sasha Levin <levinsasha928@gmail.com> | 2011-12-04 19:36:28 +0200 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2011-12-27 11:22:20 +0200 |
commit | cdfca7b346e6dbab1ba33260c28ccb8333485a5b (patch) | |
tree | 423d4487ee5604a69943e8daade01fbec1879ef6 /virt | |
parent | 3f745f1e224e05e845a15760a55f3fd323f7a753 (diff) | |
download | kernel-common-cdfca7b346e6dbab1ba33260c28ccb8333485a5b.tar.gz kernel-common-cdfca7b346e6dbab1ba33260c28ccb8333485a5b.tar.bz2 kernel-common-cdfca7b346e6dbab1ba33260c28ccb8333485a5b.zip |
KVM: Use kmemdup() instead of kmalloc/memcpy
Switch to kmemdup() in two places to shorten the code and avoid possible bugs.
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'virt')
-rw-r--r-- | virt/kvm/kvm_main.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index e289486edc6d..a6e612fced73 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -2591,13 +2591,12 @@ int kvm_io_bus_unregister_dev(struct kvm *kvm, enum kvm_bus bus_idx, int i, r; struct kvm_io_bus *new_bus, *bus; - new_bus = kzalloc(sizeof(struct kvm_io_bus), GFP_KERNEL); + bus = kvm->buses[bus_idx]; + + new_bus = kmemdup(bus, sizeof(*bus), GFP_KERNEL); if (!new_bus) return -ENOMEM; - bus = kvm->buses[bus_idx]; - memcpy(new_bus, bus, sizeof(struct kvm_io_bus)); - r = -ENOENT; for (i = 0; i < new_bus->dev_count; i++) if (new_bus->range[i].dev == dev) { |