mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-24 14:41:02 +07:00
platform/x86: thinkpad_acpi: Use strndup_user() in dispatch_proc_write()
Simplify the user copy code by using strndup_user(). Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
This commit is contained in:
parent
be51bd4585
commit
35d13c7a05
@ -885,19 +885,11 @@ static ssize_t dispatch_proc_write(struct file *file,
|
||||
|
||||
if (!ibm || !ibm->write)
|
||||
return -EINVAL;
|
||||
if (count > PAGE_SIZE - 1)
|
||||
return -EINVAL;
|
||||
|
||||
kernbuf = kmalloc(count + 1, GFP_KERNEL);
|
||||
if (!kernbuf)
|
||||
return -ENOMEM;
|
||||
kernbuf = strndup_user(userbuf, PAGE_SIZE);
|
||||
if (IS_ERR(kernbuf))
|
||||
return PTR_ERR(kernbuf);
|
||||
|
||||
if (copy_from_user(kernbuf, userbuf, count)) {
|
||||
kfree(kernbuf);
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
kernbuf[count] = 0;
|
||||
ret = ibm->write(kernbuf);
|
||||
if (ret == 0)
|
||||
ret = count;
|
||||
|
Loading…
Reference in New Issue
Block a user