diff options
author | Denis Efremov <efremov@linux.com> | 2020-06-03 13:11:31 +0300 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2020-06-04 14:41:05 -0400 |
commit | 7ec28e264f2e52089c14c6f8eba1ce7b6501e59b (patch) | |
tree | f258335eb06355778e8f4817a431cfe5a42f5d34 /virt/kvm/kvm_main.c | |
parent | 0e96edd9a9c2e75ece7f581d4f75d26b38cd53ba (diff) | |
download | linux-stable-7ec28e264f2e52089c14c6f8eba1ce7b6501e59b.tar.gz linux-stable-7ec28e264f2e52089c14c6f8eba1ce7b6501e59b.tar.bz2 linux-stable-7ec28e264f2e52089c14c6f8eba1ce7b6501e59b.zip |
KVM: Use vmemdup_user()
Replace opencoded alloc and copy with vmemdup_user().
Signed-off-by: Denis Efremov <efremov@linux.com>
Message-Id: <20200603101131.2107303-1-efremov@linux.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'virt/kvm/kvm_main.c')
-rw-r--r-- | virt/kvm/kvm_main.c | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 3577eb84eac0..4db151f6101e 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -3746,21 +3746,18 @@ static long kvm_vm_ioctl(struct file *filp, if (routing.flags) goto out; if (routing.nr) { - r = -ENOMEM; - entries = vmalloc(array_size(sizeof(*entries), - routing.nr)); - if (!entries) - goto out; - r = -EFAULT; urouting = argp; - if (copy_from_user(entries, urouting->entries, - routing.nr * sizeof(*entries))) - goto out_free_irq_routing; + entries = vmemdup_user(urouting->entries, + array_size(sizeof(*entries), + routing.nr)); + if (IS_ERR(entries)) { + r = PTR_ERR(entries); + goto out; + } } r = kvm_set_irq_routing(kvm, entries, routing.nr, routing.flags); -out_free_irq_routing: - vfree(entries); + kvfree(entries); break; } #endif /* CONFIG_HAVE_KVM_IRQ_ROUTING */ |