Re: [PATCH 1/2] sparc: Use kmalloc_array() in three functions

2016-08-29 Thread Paolo Bonzini
On 29/08/2016 13:57, walter harms wrote: > > > - buf = kmalloc(sizeof(char) * (count + 1), GFP_KERNEL); > > > + buf = kmalloc_array(count + 1, sizeof(*buf), GFP_KERNEL); > > > if (!buf) > > > return -ENOMEM; > > > > > > > Here it's probably best to just remove sizeof(char) complete

Re: [PATCH 1/2] sparc: Use kmalloc_array() in three functions

2016-08-29 Thread walter harms
Am 29.08.2016 11:47, schrieb Paolo Bonzini: > > > On 25/08/2016 10:22, SF Markus Elfring wrote: >> --- a/arch/sparc/kernel/led.c >> +++ b/arch/sparc/kernel/led.c >> @@ -69,7 +69,7 @@ static ssize_t led_proc_write(struct file *file, const >> char __user *buffer, >> if (count > LED_MAX_LENG

Re: [PATCH 1/2] sparc: Use kmalloc_array() in three functions

2016-08-29 Thread SF Markus Elfring
>> @@ -69,7 +69,7 @@ static ssize_t led_proc_write(struct file *file, const >> char __user *buffer, >> if (count > LED_MAX_LENGTH) >> count = LED_MAX_LENGTH; >> >> -buf = kmalloc(sizeof(char) * (count + 1), GFP_KERNEL); >> +buf = kmalloc_array(count + 1, sizeof(*buf), G

Re: [PATCH 1/2] sparc: Use kmalloc_array() in three functions

2016-08-29 Thread Paolo Bonzini
On 25/08/2016 10:22, SF Markus Elfring wrote: > --- a/arch/sparc/kernel/led.c > +++ b/arch/sparc/kernel/led.c > @@ -69,7 +69,7 @@ static ssize_t led_proc_write(struct file *file, const char > __user *buffer, > if (count > LED_MAX_LENGTH) > count = LED_MAX_LENGTH; > > -

[PATCH 1/2] sparc: Use kmalloc_array() in three functions

2016-08-25 Thread SF Markus Elfring
From: Markus Elfring Date: Thu, 25 Aug 2016 09:52:44 +0200 * Multiplications for the size determination of memory allocations indicated that array data structures should be processed. Thus reuse the corresponding function "kmalloc_array". This issue was detected by using the Coccinelle sof