aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Elfring <elfring@users.sourceforge.net>2016-08-28 12:40:08 -0400
committerPaul Mackerras <paulus@ozlabs.org>2016-09-11 20:13:01 -0400
commit90235dc19e5ccd85ad17ebbf51041770e87540a0 (patch)
tree309224dc42c591a62fe2d3a991918dbfc4bc3dd8
parentb0ac477bc4efd6b9a3eccc106e597edf27546c11 (diff)
KVM: PPC: e500: Use kmalloc_array() in kvmppc_e500_tlb_init()
* A multiplication for the size determination of a memory allocation indicated that an array data structure should be processed. Thus use the corresponding function "kmalloc_array". * Replace the specification of a data structure by a pointer dereference to make the corresponding size determination a bit safer according to the Linux coding style convention. Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
-rw-r--r--arch/powerpc/kvm/e500_mmu.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/arch/powerpc/kvm/e500_mmu.c b/arch/powerpc/kvm/e500_mmu.c
index 2be2afc4b722..0a2eeb143e87 100644
--- a/arch/powerpc/kvm/e500_mmu.c
+++ b/arch/powerpc/kvm/e500_mmu.c
@@ -905,8 +905,6 @@ static int vcpu_mmu_init(struct kvm_vcpu *vcpu,
905int kvmppc_e500_tlb_init(struct kvmppc_vcpu_e500 *vcpu_e500) 905int kvmppc_e500_tlb_init(struct kvmppc_vcpu_e500 *vcpu_e500)
906{ 906{
907 struct kvm_vcpu *vcpu = &vcpu_e500->vcpu; 907 struct kvm_vcpu *vcpu = &vcpu_e500->vcpu;
908 int entry_size = sizeof(struct kvm_book3e_206_tlb_entry);
909 int entries = KVM_E500_TLB0_SIZE + KVM_E500_TLB1_SIZE;
910 908
911 if (e500_mmu_host_init(vcpu_e500)) 909 if (e500_mmu_host_init(vcpu_e500))
912 goto err; 910 goto err;
@@ -921,7 +919,10 @@ int kvmppc_e500_tlb_init(struct kvmppc_vcpu_e500 *vcpu_e500)
921 vcpu_e500->gtlb_params[1].ways = KVM_E500_TLB1_SIZE; 919 vcpu_e500->gtlb_params[1].ways = KVM_E500_TLB1_SIZE;
922 vcpu_e500->gtlb_params[1].sets = 1; 920 vcpu_e500->gtlb_params[1].sets = 1;
923 921
924 vcpu_e500->gtlb_arch = kmalloc(entries * entry_size, GFP_KERNEL); 922 vcpu_e500->gtlb_arch = kmalloc_array(KVM_E500_TLB0_SIZE +
923 KVM_E500_TLB1_SIZE,
924 sizeof(*vcpu_e500->gtlb_arch),
925 GFP_KERNEL);
925 if (!vcpu_e500->gtlb_arch) 926 if (!vcpu_e500->gtlb_arch)
926 return -ENOMEM; 927 return -ENOMEM;
927 928