Commit 5588b29a authored by Geliang Tang's avatar Geliang Tang Committed by Michael Ellerman

powerpc/powernv: use memdup_user

Use memdup_user() helper instead of open-coding to simplify the code.
Signed-off-by: default avatarGeliang Tang <geliangtang@gmail.com>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
parent 31f8eb75
...@@ -241,15 +241,9 @@ static ssize_t opal_prd_write(struct file *file, const char __user *buf, ...@@ -241,15 +241,9 @@ static ssize_t opal_prd_write(struct file *file, const char __user *buf,
size = be16_to_cpu(hdr.size); size = be16_to_cpu(hdr.size);
msg = kmalloc(size, GFP_KERNEL); msg = memdup_user(buf, size);
if (!msg) if (IS_ERR(msg))
return -ENOMEM; return PTR_ERR(msg);
rc = copy_from_user(msg, buf, size);
if (rc) {
size = -EFAULT;
goto out_free;
}
rc = opal_prd_msg(msg); rc = opal_prd_msg(msg);
if (rc) { if (rc) {
...@@ -257,7 +251,6 @@ static ssize_t opal_prd_write(struct file *file, const char __user *buf, ...@@ -257,7 +251,6 @@ static ssize_t opal_prd_write(struct file *file, const char __user *buf,
size = -EIO; size = -EIO;
} }
out_free:
kfree(msg); kfree(msg);
return size; return size;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment