Skip to content
Snippets Groups Projects
Commit c9b8fecd authored by Paolo Bonzini's avatar Paolo Bonzini
Browse files

KVM: use kvcalloc for array allocations


Instead of using array_size, use a function that takes care of the
multiplication.  While at it, switch to kvcalloc since this allocation
should not be very large.

Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 6d849191
No related branches found
No related tags found
No related merge requests found
...@@ -1290,8 +1290,7 @@ int kvm_dev_ioctl_get_cpuid(struct kvm_cpuid2 *cpuid, ...@@ -1290,8 +1290,7 @@ int kvm_dev_ioctl_get_cpuid(struct kvm_cpuid2 *cpuid,
if (sanity_check_entries(entries, cpuid->nent, type)) if (sanity_check_entries(entries, cpuid->nent, type))
return -EINVAL; return -EINVAL;
array.entries = vzalloc(array_size(sizeof(struct kvm_cpuid_entry2), array.entries = kvcalloc(sizeof(struct kvm_cpuid_entry2), cpuid->nent, GFP_KERNEL);
cpuid->nent));
if (!array.entries) if (!array.entries)
return -ENOMEM; return -ENOMEM;
...@@ -1309,7 +1308,7 @@ int kvm_dev_ioctl_get_cpuid(struct kvm_cpuid2 *cpuid, ...@@ -1309,7 +1308,7 @@ int kvm_dev_ioctl_get_cpuid(struct kvm_cpuid2 *cpuid,
r = -EFAULT; r = -EFAULT;
out_free: out_free:
vfree(array.entries); kvfree(array.entries);
return r; return r;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment