summaryrefslogtreecommitdiff
path: root/arch/powerpc/platforms/pseries/reconfig.c
diff options
context:
space:
mode:
authorGeliang Tang <geliangtang@gmail.com>2017-04-29 09:45:15 +0800
committerMichael Ellerman <mpe@ellerman.id.au>2017-07-24 21:23:25 +1000
commit3783225130f01ea86fc0ee477a0e72c102ae2a4b (patch)
treee9b38322724aa926c81264b5edccc77944d99cc7 /arch/powerpc/platforms/pseries/reconfig.c
parent446183e4069e0b62cedfd72ccb90b801b7a5aa98 (diff)
powerpc/pseries: use memdup_user_nul
Use memdup_user_nul() 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/pseries/reconfig.c')
-rw-r--r--arch/powerpc/platforms/pseries/reconfig.c13
1 files changed, 3 insertions, 10 deletions
diff --git a/arch/powerpc/platforms/pseries/reconfig.c b/arch/powerpc/platforms/pseries/reconfig.c
index e5bf1e84047f..431f513586a9 100644
--- a/arch/powerpc/platforms/pseries/reconfig.c
+++ b/arch/powerpc/platforms/pseries/reconfig.c
@@ -367,16 +367,9 @@ static ssize_t ofdt_write(struct file *file, const char __user *buf, size_t coun
char *kbuf;
char *tmp;
- if (!(kbuf = kmalloc(count + 1, GFP_KERNEL))) {
- rv = -ENOMEM;
- goto out;
- }
- if (copy_from_user(kbuf, buf, count)) {
- rv = -EFAULT;
- goto out;
- }
-
- kbuf[count] = '\0';
+ kbuf = memdup_user_nul(buf, count);
+ if (IS_ERR(kbuf))
+ return PTR_ERR(kbuf);
tmp = strchr(kbuf, ' ');
if (!tmp) {