lkml.org 
[lkml]   [2018]   [Feb]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRE: [PATCH v1] platform/x86: wmi: Replace kmalloc + sprintf() with kasprintf()
Date
From: Andy Shevchenko
> Sent: 16 February 2018 15:40
>
> 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.
It might even do the printf twice just to get the length.

David


\
 
 \ /
  Last update: 2018-02-16 16:55    [W:0.061 / U:0.084 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site