lkml.org 
[lkml]   [2016]   [Aug]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Subject[PATCH 1/5] powerpc-mpic: Use kmalloc_array() in mpic_init()
    From
    Date
    From: Markus Elfring <elfring@users.sourceforge.net>
    Date: Mon, 29 Aug 2016 11:00:11 +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.

    Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
    ---
    arch/powerpc/sysdev/mpic.c | 5 +++--
    1 file changed, 3 insertions(+), 2 deletions(-)

    diff --git a/arch/powerpc/sysdev/mpic.c b/arch/powerpc/sysdev/mpic.c
    index 7de45b2..5e79c0d24 100644
    --- a/arch/powerpc/sysdev/mpic.c
    +++ b/arch/powerpc/sysdev/mpic.c
    @@ -1641,8 +1641,9 @@ void __init mpic_init(struct mpic *mpic)

    #ifdef CONFIG_PM
    /* allocate memory to save mpic state */
    - mpic->save_data = kmalloc(mpic->num_sources * sizeof(*mpic->save_data),
    - GFP_KERNEL);
    + mpic->save_data = kmalloc_array(mpic->num_sources,
    + sizeof(*mpic->save_data),
    + GFP_KERNEL);
    BUG_ON(mpic->save_data == NULL);
    #endif

    --
    2.9.3
    \
     
     \ /
      Last update: 2016-09-17 09:58    [W:4.025 / U:0.096 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site