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>
This commit is contained in:
Geliang Tang 2017-04-29 09:45:15 +08:00 committed by Michael Ellerman
parent 446183e406
commit 3783225130
1 changed files with 3 additions and 10 deletions

View File

@ -367,16 +367,9 @@ static ssize_t ofdt_write(struct file *file, const char __user *buf, size_t coun
char *kbuf; char *kbuf;
char *tmp; char *tmp;
if (!(kbuf = kmalloc(count + 1, GFP_KERNEL))) { kbuf = memdup_user_nul(buf, count);
rv = -ENOMEM; if (IS_ERR(kbuf))
goto out; return PTR_ERR(kbuf);
}
if (copy_from_user(kbuf, buf, count)) {
rv = -EFAULT;
goto out;
}
kbuf[count] = '\0';
tmp = strchr(kbuf, ' '); tmp = strchr(kbuf, ' ');
if (!tmp) { if (!tmp) {