lkml.org 
[lkml]   [2016]   [Aug]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 1/2] sparc: Use kmalloc_array() in three functions
From
Date
>> @@ -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), GFP_KERNEL);
>> if (!buf)
>> return -ENOMEM;
>>
>
> Here it's probably best to just remove sizeof(char) completely,
> as it's 1 by definition.

Would you like to be prepared anyhow that the shown buffer variable
could eventually store other data than ordinary single byte characters?

Regards,
Markus

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