From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754131AbcICUlC (ORCPT ); Sat, 3 Sep 2016 16:41:02 -0400 Received: from mout.web.de ([212.227.17.11]:61242 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751983AbcICUlB (ORCPT ); Sat, 3 Sep 2016 16:41:01 -0400 To: kernel-janitors@vger.kernel.org, Guan Xuetao Cc: linux-kernel@vger.kernel.org, Julia Lawall , Paolo Bonzini From: SF Markus Elfring Subject: [PATCH] unicore32-pm: Use kmalloc_array() in puv3_pm_init() Message-ID: Date: Sat, 3 Sep 2016 22:40:41 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:twpaL9Z114CIN2juEvRwUZ/JoAsKCR+yC0foe9TcmiJLaRWM9Cq IpQY5Xf+juil+51qi4oLdJjZpq6xP99KlmWtJ6l2fo24k4Unz6COw5Do5IYt/gQZzQ2g9qo U9mryY4ItRodGvlFXDDhwsmRAuBQST6LYK5W3veti92Nk28sm7mLuvPiB0Sj4Tb1GHRyi7h VjsKbuFgeL1EIb9nLZUHg== X-UI-Out-Filterresults: notjunk:1;V01:K0:XGXCPg5wTZI=:VlwcApuSfaVb1ScrKlpa4X ccGF0Mxl5fS1c52AGLxzsM4yMu4NVzqs+ulmBXjmV71i6V8IZuqVaR8yssfTDd2MqXTZ9dFbG HFdHTtpNho3zdvd2Go/vhiTLIFOVSkznyXtVkY4kdzWoEa+6/7DWq4Hl02DyuiVesnU4vOH2y lHCt5bs6TVu6334OIfRT1i9eTqWsq9Hyav0DFs4J9H4TqXOKjZ/KiKSHzdLb+MPKixeD9kk59 RCqBxhD4HKCsxxLOAFBaiJE/NSOrNx3yHDl6oYzduQy4vXUGZ3Z/cRmmpz7QZKjaMmGfFZPO0 c6Cp3UPxdZu9aqwQlX44XNR0TBX5DvsNM6UKY9qruNijTPtDth7poF7GqEOIobVMZmjySuvln A758yYLpb4hEBn17N0FKaXoSQwfzqdsL824M4oSmCIrzuJGTYwRQI08bs5FLaRyqZA8Ti6P0J JMvl56kBHyL2oU9PByu5ThjzIVjfwg1aXHYtRfsPoNsHr3JXhf3WxHEmkgTOLxUJ8B+hdQw6T 4EvD8YS6YTOG25N6ymwp6fxi2uLhHni7h9TeOkwB8qF92e8RpBuNyb7uVKANAYYzgLkz7/iIN YAYxlE3cUR0aL+Uic/ujoDNWYH/lWLeogAKICjqh9JDCPiHyPXBaVAt9Xgz+TAeZFsyarOY/3 yOxfW8MgLMLvouXXBTUWfAh0JYQ+BZS7lGPbhYbjIDWOVzS8cJdyqlfxgVR+qZVKngmIPDZlm Vl2Op9v2AoTbUKWGEOFnpLb99oR9UvW1BiOISJFT28XgfYRFcRAvT1b6AVEsr84wcRb8pJS/m DBmyDtk Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Markus Elfring Date: Sat, 3 Sep 2016 22:34:32 +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 --- arch/unicore32/kernel/pm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/unicore32/kernel/pm.c b/arch/unicore32/kernel/pm.c index 784bc2d..f5455a9 100644 --- a/arch/unicore32/kernel/pm.c +++ b/arch/unicore32/kernel/pm.c @@ -109,8 +109,9 @@ static int __init puv3_pm_init(void) return -EINVAL; } - sleep_save = kmalloc(puv3_cpu_pm_fns->save_count - * sizeof(unsigned long), GFP_KERNEL); + sleep_save = kmalloc_array(puv3_cpu_pm_fns->save_count, + sizeof(*sleep_save), + GFP_KERNEL); if (!sleep_save) { printk(KERN_ERR "failed to alloc memory for pm save\n"); return -ENOMEM; -- 2.9.3