[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHp75VcjpZy75_t6z-9nN8hP=g0qb-skjOU4QtkUZxL7YRFUHQ@mail.gmail.com>
Date: Fri, 16 Feb 2018 21:30:03 +0200
From: Andy Shevchenko <andy.shevchenko@...il.com>
To: David Laight <David.Laight@...lab.com>
Cc: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Darren Hart <dvhart@...radead.org>,
"platform-driver-x86@...r.kernel.org"
<platform-driver-x86@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v1] platform/x86: wmi: Replace kmalloc + sprintf() with kasprintf()
On Fri, Feb 16, 2018 at 5:55 PM, David Laight <David.Laight@...lab.com> 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
Powered by blists - more mailing lists