Re: x86-ksysfs: Use kmalloc_array() in create_setup_data_nodes()

2016-09-07 Thread Kees Cook
On Wed, Sep 7, 2016 at 9:37 AM, Joe Perches wrote: > On Wed, 2016-09-07 at 09:23 -0700, Kees Cook wrote: >> Fixing these kmalloc calls would be a nice thing to clean up >> everywhere. > > Dubious as gcc cannot currently optimize known small fixed size > allocations with alloc_array and will always

Re: x86-ksysfs: Use kmalloc_array() in create_setup_data_nodes()

2016-09-07 Thread SF Markus Elfring
> Fixing these kmalloc calls would be a nice thing to clean up everywhere. Thanks for your acknowledgement of such a software improvement opportunity. > Since it is a mistake people may continue to make, I think it would > make sense to add a coccinelle script that can do this to the > existing

Re: x86-ksysfs: Use kmalloc_array() in create_setup_data_nodes()

2016-09-07 Thread Joe Perches
On Wed, 2016-09-07 at 09:23 -0700, Kees Cook wrote: > Fixing these kmalloc calls would be a nice thing to clean up > everywhere. Dubious as gcc cannot currently optimize known small fixed size allocations with alloc_array and will always perform the multiplication. Also the style of sizeof(*ptr)

Re: x86-ksysfs: Use kmalloc_array() in create_setup_data_nodes()

2016-09-07 Thread Kees Cook
On Wed, Sep 7, 2016 at 4:45 AM, SF Markus Elfring wrote: >>> Would the following script (for the semantic patch language) >>> be useful enough for further development considerations? >>> >>> usage_of_kmalloc_array1-excerpt2.cocci: >>> @replacement2@ >>> expression count, pointer, target; >>> @@ >>

Re: x86-ksysfs: Use kmalloc_array() in create_setup_data_nodes()

2016-09-07 Thread SF Markus Elfring
>> Would the following script (for the semantic patch language) >> be useful enough for further development considerations? >> >> usage_of_kmalloc_array1-excerpt2.cocci: >> @replacement2@ >> expression count, pointer, target; >> @@ >> target = >> - kmalloc(sizeof(*pointer) * (count) >> +

Re: x86-ksysfs: Use kmalloc_array() in create_setup_data_nodes()

2016-09-07 Thread Paolo Bonzini
On 07/09/2016 13:17, SF Markus Elfring wrote: >>> Are you looking for further possibilities to improve the involved >>> source code search patterns? >> >> Why are you not answering the simple question that was asked? > > I find that I answered it to some degree. > > It can be that you do not re

Re: x86-ksysfs: Use kmalloc_array() in create_setup_data_nodes()

2016-09-07 Thread SF Markus Elfring
>> Are you looking for further possibilities to improve the involved >> source code search patterns? > > Why are you not answering the simple question that was asked? I find that I answered it to some degree. It can be that you do not really like the kind of answer that I chose a moment ago. But

Re: x86-ksysfs: Use kmalloc_array() in create_setup_data_nodes()

2016-09-07 Thread Paolo Bonzini
On 07/09/2016 09:49, SF Markus Elfring wrote: >>> 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 sof

Re: x86-ksysfs: Use kmalloc_array() in create_setup_data_nodes()

2016-09-07 Thread SF Markus Elfring
>> 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. > > Which rule-set was used? Do you get an u

Re: [PATCH] x86-ksysfs: Use kmalloc_array() in create_setup_data_nodes()

2016-09-06 Thread Kees Cook
On Sun, Sep 4, 2016 at 4:23 PM, SF Markus Elfring wrote: > From: Markus Elfring > Date: Sun, 4 Sep 2016 22:15:09 +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 "kmallo

[PATCH] x86-ksysfs: Use kmalloc_array() in create_setup_data_nodes()

2016-09-04 Thread SF Markus Elfring
From: Markus Elfring Date: Sun, 4 Sep 2016 22:15:09 +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.