lkml.org 
[lkml]   [2017]   [Feb]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Subject[PATCH 10/14] RDMA/cxgb4: Use kmalloc_array() in c4iw_id_table_alloc()
    From
    Date
    From: Markus Elfring <elfring@users.sourceforge.net>
    Date: Wed, 8 Feb 2017 20:03:24 +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 "kmalloc_array".

    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>
    ---
    drivers/infiniband/hw/cxgb4/id_table.c | 5 +++--
    1 file changed, 3 insertions(+), 2 deletions(-)

    diff --git a/drivers/infiniband/hw/cxgb4/id_table.c b/drivers/infiniband/hw/cxgb4/id_table.c
    index 0161ae6ad629..51a0b7244e35 100644
    --- a/drivers/infiniband/hw/cxgb4/id_table.c
    +++ b/drivers/infiniband/hw/cxgb4/id_table.c
    @@ -93,8 +93,9 @@ int c4iw_id_table_alloc(struct c4iw_id_table *alloc, u32 start, u32 num,
    alloc->last = 0;
    alloc->max = num;
    spin_lock_init(&alloc->lock);
    - alloc->table = kmalloc(BITS_TO_LONGS(num) * sizeof(long),
    - GFP_KERNEL);
    + alloc->table = kmalloc_array(BITS_TO_LONGS(num),
    + sizeof(*alloc->table),
    + GFP_KERNEL);
    if (!alloc->table)
    return -ENOMEM;

    --
    2.11.1
    \
     
     \ /
      Last update: 2017-02-08 22:22    [W:4.033 / U:0.080 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site