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


Groups > linux.kernel > #1470929

[PATCH 4/5] ia64/mm/tlb: Use kmalloc_array() in ia64_itr_entry()

From SF Markus Elfring <elfring@users.sourceforge.net>
Newsgroups linux.kernel
Subject [PATCH 4/5] ia64/mm/tlb: Use kmalloc_array() in ia64_itr_entry()
Date 2016-08-26 20:20 +0200
Message-ID <satTs-266-23@gated-at.bofh.it> (permalink)
References <satJM-22D-31@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 26 Aug 2016 19:43:34 +0200

* 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".

  This issue was detected by using the Coccinelle software.

* 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>
---
 arch/ia64/mm/tlb.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/ia64/mm/tlb.c b/arch/ia64/mm/tlb.c
index 6d2f83d..30870d1 100644
--- a/arch/ia64/mm/tlb.c
+++ b/arch/ia64/mm/tlb.c
@@ -429,8 +429,9 @@ int ia64_itr_entry(u64 target_mask, u64 va, u64 pte, u64 log_size)
 	int cpu = smp_processor_id();
 
 	if (!ia64_idtrs[cpu]) {
-		ia64_idtrs[cpu] = kmalloc(2 * IA64_TR_ALLOC_MAX *
-				sizeof (struct ia64_tr_entry), GFP_KERNEL);
+		ia64_idtrs[cpu] = kmalloc_array(2 * IA64_TR_ALLOC_MAX,
+						sizeof(*ia64_idtrs[cpu]),
+						GFP_KERNEL);
 		if (!ia64_idtrs[cpu])
 			return -ENOMEM;
 	}
-- 
2.9.3

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


Thread

[PATCH 0/5] IA64: Fine-tuning for some function implementations SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-26 20:10 +0200
  [PATCH 1/5] IA64-IRQ: Use kmalloc_array() in sn_irq_lh_init() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-26 20:10 +0200
    Re: [PATCH 1/5] IA64-IRQ: Use kmalloc_array() in sn_irq_lh_init() Julia Lawall <julia.lawall@lip6.fr> - 2016-08-26 22:00 +0200
      Re: [PATCH 1/5] IA64-IRQ: Use kmalloc_array() in sn_irq_lh_init() Joe Perches <joe@perches.com> - 2016-08-26 23:10 +0200
        Re: [PATCH 1/5] IA64-IRQ: Use kmalloc_array() in sn_irq_lh_init() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-27 09:10 +0200
          Re: [PATCH 1/5] IA64-IRQ: Use kmalloc_array() in sn_irq_lh_init() Joe Perches <joe@perches.com> - 2016-08-28 02:50 +0200
            Re: IA64-IRQ: Use kmalloc_array() in sn_irq_lh_init() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-28 09:40 +0200
            Re: [PATCH 1/5] IA64-IRQ: Use kmalloc_array() in sn_irq_lh_init() Julia Lawall <julia.lawall@lip6.fr> - 2016-08-28 11:30 +0200
              Re: [PATCH 1/5] IA64-IRQ: Use kmalloc_array() in sn_irq_lh_init() Joe Perches <joe@perches.com> - 2016-08-28 20:40 +0200
      Re: IA64-IRQ: Use kmalloc_array() in sn_irq_lh_init() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-27 08:30 +0200
    Re: [PATCH 1/5] IA64-IRQ: Use kmalloc_array() in sn_irq_lh_init() kbuild test robot <lkp@intel.com> - 2016-08-26 22:30 +0200
    Re: [PATCH 1/5] IA64-IRQ: Use kmalloc_array() in sn_irq_lh_init() walter harms <wharms@bfs.de> - 2016-08-27 10:50 +0200
  [PATCH 2/5] IA64-IRQ: Delete unnecessary braces SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-26 20:20 +0200
    Re: [PATCH 2/5] IA64-IRQ: Delete unnecessary braces kbuild test robot <lkp@intel.com> - 2016-08-26 22:30 +0200
  [PATCH 5/5] ia64/mm/tlb: Delete unnecessary braces SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-26 20:20 +0200
    Re: [PATCH 5/5] ia64/mm/tlb: Delete unnecessary braces kbuild test robot <lkp@intel.com> - 2016-08-26 22:50 +0200
      Re: ia64/mm/tlb: Delete unnecessary braces SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-27 09:30 +0200
  [PATCH 3/5] ia64/mm/tlb: Fix indentation in ia64_global_tlb_purge() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-26 20:20 +0200
  [PATCH 4/5] ia64/mm/tlb: Use kmalloc_array() in ia64_itr_entry() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-26 20:20 +0200

csiph-web