Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1563848

[PATCH 10/11] KVM: PPC: e500: Use kcalloc() in e500_mmu_host_init()

From SF Markus Elfring <elfring@users.sourceforge.net>
Newsgroups linux.kernel
Subject [PATCH 10/11] KVM: PPC: e500: Use kcalloc() in e500_mmu_host_init()
Date 2017-01-20 19:30 +0100
Message-ID <t1M6K-2gO-7@gated-at.bofh.it> (permalink)
References <t1LX4-2d6-19@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 20 Jan 2017 16:30:18 +0100

* A multiplication for the size determination of a memory allocation
  indicated that an array data structure should be processed.
  Thus use the corresponding function "kcalloc".

  This issue was detected by using the Coccinelle software.

* Replace the specification of a data type 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>
---
 arch/powerpc/kvm/e500_mmu_host.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/kvm/e500_mmu_host.c b/arch/powerpc/kvm/e500_mmu_host.c
index b0333cc737dd..a1af2f445988 100644
--- a/arch/powerpc/kvm/e500_mmu_host.c
+++ b/arch/powerpc/kvm/e500_mmu_host.c
@@ -797,9 +797,8 @@ int e500_mmu_host_init(struct kvmppc_vcpu_e500 *vcpu_e500)
 	host_tlb_params[0].sets =
 		host_tlb_params[0].entries / host_tlb_params[0].ways;
 	host_tlb_params[1].sets = 1;
-
-	vcpu_e500->h2g_tlb1_rmap = kzalloc(sizeof(unsigned int) *
-					   host_tlb_params[1].entries,
+	vcpu_e500->h2g_tlb1_rmap = kcalloc(host_tlb_params[1].entries,
+					   sizeof(*vcpu_e500->h2g_tlb1_rmap),
 					   GFP_KERNEL);
 	if (!vcpu_e500->h2g_tlb1_rmap)
 		return -EINVAL;
-- 
2.11.0

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 00/11] PowerPC-KVM: Fine-tuning for some function  implementations SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-20 19:20 +0100
  [PATCH 02/11] KVM: PPC: Book3S HV: Improve a size determination in  kvmppc_alloc_hpt() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-20 19:30 +0100
  [PATCH 07/11] KVM: PPC: Book3S HV: Improve size determinations in  five functions SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-20 19:30 +0100
  [PATCH 01/11] KVM: PPC: Book3S HV: Move assignments for the variable  "err" in kvm_htab_write() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-20 19:30 +0100
    Re: [PATCH 01/11] KVM: PPC: Book3S HV: Move assignments for the  variable "err" in kvm_htab_write() Paolo Bonzini <pbonzini@redhat.com> - 2017-01-23 15:20 +0100
  [PATCH 10/11] KVM: PPC: e500: Use kcalloc() in e500_mmu_host_init() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-20 19:30 +0100
  [PATCH 04/11] KVM: PPC: Book3S HV: Use common error handling code in  kvmppc_clr_passthru_irq() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-20 19:30 +0100
  [PATCH 03/11] KVM: PPC: Book3S HV: Move error code assignments in two  functions SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-20 19:30 +0100
    Re: [PATCH 03/11] KVM: PPC: Book3S HV: Move error code assignments in  two functions Paolo Bonzini <pbonzini@redhat.com> - 2017-01-23 15:20 +0100
  [PATCH 06/11] KVM: PPC: Book3S HV: Use kcalloc() in  kvmppc_alloc_host_rm_ops() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-20 19:30 +0100
  [PATCH 09/11] KVM: PPC: Book3S: Improve a size determination in two  functions SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-20 19:30 +0100
    Re: [PATCH 09/11] KVM: PPC: Book3S: Improve a size determination in  two functions kbuild test robot <lkp@intel.com> - 2017-01-21 07:40 +0100
  [PATCH 11/11] KVM: PPC: Return directly after a failed  copy_from_user() in two functions SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-20 19:40 +0100
  [PATCH 08/11] KVM: PPC: Book3S: Use seq_puts() in xics_debug_show() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-20 19:40 +0100
  [PATCH 05/11] KVM: PPC: Book3S HV: Adjust nine checks for null  pointers SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-20 19:40 +0100
    Re: [PATCH 05/11] KVM: PPC: Book3S HV: Adjust nine checks for null  pointers Thomas Huth <thuth@redhat.com> - 2017-01-23 20:30 +0100

csiph-web