projects
/
linux.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
65c6ea3
)
platform/x86: thinkpad_acpi: Switch to memdup_user_nul() helper
author
Ruan Jinjie
<ruanjinjie@huawei.com>
Thu, 10 Aug 2023 12:20:12 +0000
(20:20 +0800)
committer
Hans de Goede
<hdegoede@redhat.com>
Mon, 21 Aug 2023 12:00:38 +0000
(14:00 +0200)
Use memdup_user_nul() helper instead of open-coding to simplify the code.
Signed-off-by: Ruan Jinjie <ruanjinjie@huawei.com>
Link:
https://lore.kernel.org/r/20230810122012.2110410-1-ruanjinjie@huawei.com
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
drivers/platform/x86/thinkpad_acpi.c
patch
|
blob
|
history
diff --git
a/drivers/platform/x86/thinkpad_acpi.c
b/drivers/platform/x86/thinkpad_acpi.c
index 25cc86a4a36aa3104c8e2ef09683af59390fa750..34b8b3fb544497a9f23a0bc8de9080679cae212a 100644
(file)
--- a/
drivers/platform/x86/thinkpad_acpi.c
+++ b/
drivers/platform/x86/thinkpad_acpi.c
@@
-913,16
+913,9
@@
static ssize_t dispatch_proc_write(struct file *file,
if (count > PAGE_SIZE - 1)
return -EINVAL;
- kernbuf = kmalloc(count + 1, GFP_KERNEL);
- if (!kernbuf)
- return -ENOMEM;
-
- if (copy_from_user(kernbuf, userbuf, count)) {
- kfree(kernbuf);
- return -EFAULT;
- }
-
- kernbuf[count] = 0;
+ kernbuf = memdup_user_nul(userbuf, count);
+ if (IS_ERR(kernbuf))
+ return PTR_ERR(kernbuf);
ret = ibm->write(kernbuf);
if (ret == 0)
ret = count;