mirror of
https://github.com/torvalds/linux.git
synced 2026-05-25 15:41:52 +02:00
platform/x86: thinkpad_acpi: Switch to memdup_user_nul() helper
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>
This commit is contained in:
parent
65c6ea33e7
commit
4316c64085
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user