Skip to content

Commit c9b8fec

Browse files
committed
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: Paolo Bonzini <[email protected]>
1 parent 6d84919 commit c9b8fec

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

arch/x86/kvm/cpuid.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,8 +1290,7 @@ int kvm_dev_ioctl_get_cpuid(struct kvm_cpuid2 *cpuid,
12901290
if (sanity_check_entries(entries, cpuid->nent, type))
12911291
return -EINVAL;
12921292

1293-
array.entries = vzalloc(array_size(sizeof(struct kvm_cpuid_entry2),
1294-
cpuid->nent));
1293+
array.entries = kvcalloc(sizeof(struct kvm_cpuid_entry2), cpuid->nent, GFP_KERNEL);
12951294
if (!array.entries)
12961295
return -ENOMEM;
12971296

@@ -1309,7 +1308,7 @@ int kvm_dev_ioctl_get_cpuid(struct kvm_cpuid2 *cpuid,
13091308
r = -EFAULT;
13101309

13111310
out_free:
1312-
vfree(array.entries);
1311+
kvfree(array.entries);
13131312
return r;
13141313
}
13151314

0 commit comments

Comments
 (0)