Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1471706

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

From SF Markus Elfring <elfring@users.sourceforge.net>
Newsgroups linux.kernel
Subject Re: [PATCH 1/2] sparc: Use kmalloc_array() in three functions
Date 2016-08-29 12:40 +0200
Message-ID <sbs8W-69R-15@gated-at.bofh.it> (permalink)
References <s9YcW-6Yd-11@gated-at.bofh.it> <s9YcW-6Yd-9@gated-at.bofh.it> <sbrmx-5BR-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


>> @@ -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

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: [PATCH 1/2] sparc: Use kmalloc_array() in three functions Paolo Bonzini <pbonzini@redhat.com> - 2016-08-29 11:50 +0200
  Re: [PATCH 1/2] sparc: Use kmalloc_array() in three functions SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-29 12:40 +0200
  Re: [PATCH 1/2] sparc: Use kmalloc_array() in three functions walter harms <wharms@bfs.de> - 2016-08-29 14:00 +0200
    Re: [PATCH 1/2] sparc: Use kmalloc_array() in three functions Paolo Bonzini <pbonzini@redhat.com> - 2016-08-29 18:50 +0200

csiph-web