diff options
author | 2019-07-04 00:29:51 +0800 | |
---|---|---|
committer | 2019-07-29 18:31:48 +0300 | |
commit | 340f25ff1d4fd3bfe0d3e0769261fec8fb32ae9f (patch) | |
tree | 593f5621bb2a51675eea21279d355a65276d35aa /drivers/platform | |
parent | platform/x86: hp_accel: Add support for HP ZBook 17 G5 (diff) | |
download | linux-340f25ff1d4fd3bfe0d3e0769261fec8fb32ae9f.tar.gz linux-340f25ff1d4fd3bfe0d3e0769261fec8fb32ae9f.tar.bz2 linux-340f25ff1d4fd3bfe0d3e0769261fec8fb32ae9f.zip |
platform/x86: asus-wmi: Use kmemdup rather than duplicating its implementation
kmemdup is introduced to duplicate a region of memory in a neat way.
Rather than kmalloc/kzalloc + memcpy, which the programmer needs to
write the size twice (sometimes lead to mistakes), kmemdup improves
readability, leads to smaller code and also reduce the chances of mistakes.
Suggestion to use kmemdup rather than using kmalloc/kzalloc + memcpy.
Signed-off-by: Fuqian Huang <huangfq.daxian@gmail.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Diffstat (limited to 'drivers/platform')
-rw-r--r-- | drivers/platform/x86/asus-wmi.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c index ca28d27dae63..0c6a810fcb72 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -292,12 +292,11 @@ static int asus_wmi_evaluate_method_agfn(const struct acpi_buffer args) * Copy to dma capable address otherwise memory corruption occurs as * bios has to be able to access it. */ - input.pointer = kzalloc(args.length, GFP_DMA | GFP_KERNEL); + input.pointer = kmemdup(args.pointer, args.length, GFP_DMA | GFP_KERNEL); input.length = args.length; if (!input.pointer) return -ENOMEM; phys_addr = virt_to_phys(input.pointer); - memcpy(input.pointer, args.pointer, args.length); status = asus_wmi_evaluate_method(ASUS_WMI_METHODID_AGFN, phys_addr, 0, &retval); |