Re: [PATCH v1] platform/x86: wmi: Replace kmalloc + sprintf() with kasprintf()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Feb 16, 2018 at 5:55 PM, David Laight <David.Laight@xxxxxxxxxx> wrote:

>> kasprintf() does the job of two: kmalloc() and sprintf().
>> Replace two calls with one.
> ...
>> -             buf = kmalloc(strlen(wdriver->driver.name) + 5, GFP_KERNEL);
>> +             buf = kasprintf(GFP_KERNEL, "wmi/%s", wdriver->driver.name);
> ...
>
> Except that kasprintf() has no idea how long a buffer is needed.

Hmm...

> It might even do the printf twice just to get the length.

It does exactly that. So what?

-- 
With Best Regards,
Andy Shevchenko



[Index of Archives]     [Linux Kernel Development]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux