aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/platforms/powernv/opal-prd.c
diff options
context:
space:
mode:
authorGeliang Tang <geliangtang@gmail.com>2017-04-29 09:45:14 +0800
committerMichael Ellerman <mpe@ellerman.id.au>2017-07-24 21:48:42 +1000
commit5588b29a5cd34aec747202e95f328a4f98bfde1a (patch)
tree7d7c39fbb826660e9c30af39dc2fd3da836dda19 /arch/powerpc/platforms/powernv/opal-prd.c
parent31f8eb753522a71e12e1c7b90c17a2b3d2a2df08 (diff)
powerpc/powernv: use memdup_user
Use memdup_user() helper instead of open-coding to simplify the code. Signed-off-by: Geliang Tang <geliangtang@gmail.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Diffstat (limited to 'arch/powerpc/platforms/powernv/opal-prd.c')
-rw-r--r--arch/powerpc/platforms/powernv/opal-prd.c13
1 files changed, 3 insertions, 10 deletions
diff --git a/arch/powerpc/platforms/powernv/opal-prd.c b/arch/powerpc/platforms/powernv/opal-prd.c
index 2d6ee1c5ad85..de4dd09f4a15 100644
--- a/arch/powerpc/platforms/powernv/opal-prd.c
+++ b/arch/powerpc/platforms/powernv/opal-prd.c
@@ -241,15 +241,9 @@ static ssize_t opal_prd_write(struct file *file, const char __user *buf,
size = be16_to_cpu(hdr.size);
- msg = kmalloc(size, GFP_KERNEL);
- if (!msg)
- return -ENOMEM;
-
- rc = copy_from_user(msg, buf, size);
- if (rc) {
- size = -EFAULT;
- goto out_free;
- }
+ msg = memdup_user(buf, size);
+ if (IS_ERR(msg))
+ return PTR_ERR(msg);
rc = opal_prd_msg(msg);
if (rc) {
@@ -257,7 +251,6 @@ static ssize_t opal_prd_write(struct file *file, const char __user *buf,
size = -EIO;
}
-out_free:
kfree(msg);
return size;

Privacy Policy