Skip to content

Commit 3783225

Browse files
geliangtangmpe
authored andcommitted
powerpc/pseries: use memdup_user_nul
Use memdup_user_nul() helper instead of open-coding to simplify the code. Signed-off-by: Geliang Tang <[email protected]> Signed-off-by: Michael Ellerman <[email protected]>
1 parent 446183e commit 3783225

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

arch/powerpc/platforms/pseries/reconfig.c

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -367,16 +367,9 @@ static ssize_t ofdt_write(struct file *file, const char __user *buf, size_t coun
367367
char *kbuf;
368368
char *tmp;
369369

370-
if (!(kbuf = kmalloc(count + 1, GFP_KERNEL))) {
371-
rv = -ENOMEM;
372-
goto out;
373-
}
374-
if (copy_from_user(kbuf, buf, count)) {
375-
rv = -EFAULT;
376-
goto out;
377-
}
378-
379-
kbuf[count] = '\0';
370+
kbuf = memdup_user_nul(buf, count);
371+
if (IS_ERR(kbuf))
372+
return PTR_ERR(kbuf);
380373

381374
tmp = strchr(kbuf, ' ');
382375
if (!tmp) {

0 commit comments

Comments
 (0)