lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ef260e14-c785-cac6-b8c1-d3c5cfeb44fc@arm.com>
Date:   Thu, 8 Dec 2016 15:25:20 +0000
From:   Robin Murphy <robin.murphy@....com>
To:     Arvind Yadav <arvind.yadav.cs@...il.com>, daniel@...que.org,
        haojian.zhuang@...il.com, robert.jarzmik@...e.fr,
        linus.walleij@...aro.org
Cc:     linux-gpio@...r.kernel.org, linux-kernel@...r.kernel.org,
        linux-arm-kernel@...ts.infradead.org
Subject: Re: [PATCH V1] pinctrl:pxa:pinctrl-pxa2xx:- No need of devm functions

On 08/12/16 15:20, Robin Murphy wrote:
> On 08/12/16 14:35, Arvind Yadav wrote:
>> In functions pxa2xx_build_functions, the memory allocated for
>> 'functions' is live within the function only. After the
>> allocation it is immediately freed with devm_kfree. There is
>> no need to allocate memory for 'functions' with devm function
>> so replace devm_kcalloc  with kcalloc and devm_kfree with kfree.
>>
>> Signed-off-by: Arvind Yadav <arvind.yadav.cs@...il.com>
>> ---
>>  drivers/pinctrl/pxa/pinctrl-pxa2xx.c | 8 +++++---
>>  1 file changed, 5 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/pinctrl/pxa/pinctrl-pxa2xx.c b/drivers/pinctrl/pxa/pinctrl-pxa2xx.c
>> index 866aa3c..47b8e3a 100644
>> --- a/drivers/pinctrl/pxa/pinctrl-pxa2xx.c
>> +++ b/drivers/pinctrl/pxa/pinctrl-pxa2xx.c
>> @@ -277,7 +277,7 @@ static int pxa2xx_build_functions(struct pxa_pinctrl *pctl)
>>  	 * alternate function, 6 * npins is an absolute high limit of the number
>>  	 * of functions.
>>  	 */
>> -	functions = devm_kcalloc(pctl->dev, pctl->npins * 6,
>> +	functions = kcalloc(pctl->npins * 6,
>>  				 sizeof(*functions), GFP_KERNEL);
> 
> AFAICS, this is allocating a mere 72 bytes. Why not just declare
> 
> 	struct pxa_pinctrl_function functions[6] = {0};
> 
> locally and save *all* the bother?

Bah, ignore me, that was an incredible comprehension failure.

Sorry for the noise.

Robin.

>>  	if (!functions)
>>  		return -ENOMEM;
>> @@ -289,10 +289,12 @@ static int pxa2xx_build_functions(struct pxa_pinctrl *pctl)
>>  	pctl->functions = devm_kmemdup(pctl->dev, functions,
>>  				       pctl->nfuncs * sizeof(*functions),
>>  				       GFP_KERNEL);
>> -	if (!pctl->functions)
>> +	if (!pctl->functions) {
>> +		kfree(functions);
>>  		return -ENOMEM;
>> +	}
>>  
>> -	devm_kfree(pctl->dev, functions);
>> +	kfree(functions);
>>  	return 0;
>>  }
>>  
>>
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ