Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 37832251 authored by Geliang Tang's avatar Geliang Tang Committed by Michael Ellerman
Browse files

powerpc/pseries: use memdup_user_nul



Use memdup_user_nul() 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 446183e4
Loading
Loading
Loading
Loading
+3 −10
Original line number Diff line number Diff line
@@ -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) {