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]
Date:	Tue, 28 Jan 2014 12:46:01 +0530
From:	Manish Badarkhe <badarkhe.manish@...il.com>
To:	Dmitry Torokhov <dmitry.torokhov@...il.com>
Cc:	linux-omap@...r.kernel.org,
	"linux-samsung-soc@...r.kernel.org" 
	<linux-samsung-soc@...r.kernel.org>, linux-tegra@...r.kernel.org,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	Mark Brown <broonie@...nel.org>,
	Liam Girdwood <lgirdwood@...il.com>
Subject: Re: [PATCH V2] regulator: fixed: update to devm_* API

Hi Dmitry,

Thank you for your review.

On Tue, Jan 28, 2014 at 12:03 PM, Dmitry Torokhov
<dmitry.torokhov@...il.com> wrote:
> Hi Manish,
>
> On Tue, Jan 28, 2014 at 08:42:00AM +0530, Manish Badarkhe wrote:
>> Update the code to use devm_* API so that driver core will manage
>> resources.
>>
>> Signed-off-by: Manish Badarkhe <badarkhe.manish@...il.com>
>> ---
>> Changes since V1:
>> 1. Updated driver to use "devm_kzalloc" to "kstrdup".
>> 2. Updated commit message.
>>
>> Not tested on any board.
>>
>> :100644 100644 5ea64b9... e9763a4... M        drivers/regulator/fixed.c
>>  drivers/regulator/fixed.c |   42 ++++++++++++------------------------------
>>  1 file changed, 12 insertions(+), 30 deletions(-)
>>
>> diff --git a/drivers/regulator/fixed.c b/drivers/regulator/fixed.c
>> index 5ea64b9..e9763a4 100644
>> --- a/drivers/regulator/fixed.c
>> +++ b/drivers/regulator/fixed.c
>> @@ -132,15 +132,15 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev)
>>                              GFP_KERNEL);
>>       if (drvdata == NULL) {
>>               dev_err(&pdev->dev, "Failed to allocate device data\n");
>> -             ret = -ENOMEM;
>> -             goto err;
>> +             return -ENOMEM;
>>       }
>>
>> -     drvdata->desc.name = kstrdup(config->supply_name, GFP_KERNEL);
>> +     drvdata->desc.name = devm_kzalloc(&pdev->dev,
>> +                                       strlen(config->supply_name) + 1,
>> +                                       GFP_KERNEL);
>>       if (drvdata->desc.name == NULL) {
>>               dev_err(&pdev->dev, "Failed to allocate supply name\n");
>> -             ret = -ENOMEM;
>> -             goto err;
>> +             return -ENOMEM;
>>       }
>
> Umm, I am fairly certain that devm_kzalloc() can't be used as a
> substitute for kstrdup, at least not without accompanying memcpy.

Yes, I have provided allocation but it should be followed with assignment.
Can I modify like this,

+     drvdata->desc.name = devm_kzalloc(&pdev->dev,
+                                       strlen(config->supply_name) + 1,
+                                       GFP_KERNEL);
+     if (drvdata->desc.name)
+     sprintf(drvdata->desc.name, "%s", config->supply_name);

Thanks
Manish Badakhe
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ