platform/x86: wmi: Replace kmalloc + sprintf() with kasprintf()

kasprintf() does the job of two: kmalloc() and sprintf().
Replace two calls with one.

Reviewed-by: Darren Hart (VMware) <dvhart@infradead.org>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
This commit is contained in:
Andy Shevchenko 2018-02-16 17:40:24 +02:00
parent 04e4e88855
commit 7f166addbe
1 changed files with 1 additions and 2 deletions

View File

@ -933,12 +933,11 @@ static int wmi_dev_probe(struct device *dev)
goto probe_failure; goto probe_failure;
} }
buf = kmalloc(strlen(wdriver->driver.name) + 5, GFP_KERNEL); buf = kasprintf(GFP_KERNEL, "wmi/%s", wdriver->driver.name);
if (!buf) { if (!buf) {
ret = -ENOMEM; ret = -ENOMEM;
goto probe_string_failure; goto probe_string_failure;
} }
sprintf(buf, "wmi/%s", wdriver->driver.name);
wblock->char_dev.minor = MISC_DYNAMIC_MINOR; wblock->char_dev.minor = MISC_DYNAMIC_MINOR;
wblock->char_dev.name = buf; wblock->char_dev.name = buf;
wblock->char_dev.fops = &wmi_fops; wblock->char_dev.fops = &wmi_fops;