projects
/
GitHub
/
moto-9609
/
android_kernel_motorola_exynos9610.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
077090a
)
powerpc/nvram: use memdup_user
author
Geliang Tang
<geliangtang@gmail.com>
Sat, 29 Apr 2017 01:45:13 +0000
(09:45 +0800)
committer
Kees Cook
<keescook@chromium.org>
Wed, 28 Jun 2017 00:02:50 +0000
(17:02 -0700)
Use memdup_user() helper instead of open-coding to simplify the code.
Signed-off-by: Geliang Tang <geliangtang@gmail.com>
Signed-off-by: Kees Cook <keescook@chromium.org>
arch/powerpc/kernel/nvram_64.c
patch
|
blob
|
blame
|
history
diff --git
a/arch/powerpc/kernel/nvram_64.c
b/arch/powerpc/kernel/nvram_64.c
index eae61b044e9e3510657a4777d59c4dc0bbd06267..496d6393bd41824b565c66b731e1b4147c7e3923 100644
(file)
--- a/
arch/powerpc/kernel/nvram_64.c
+++ b/
arch/powerpc/kernel/nvram_64.c
@@
-792,21
+792,17
@@
static ssize_t dev_nvram_write(struct file *file, const char __user *buf,
count = min_t(size_t, count, size - *ppos);
count = min(count, PAGE_SIZE);
- ret = -ENOMEM;
- tmp = kmalloc(count, GFP_KERNEL);
- if (!tmp)
- goto out;
-
- ret = -EFAULT;
- if (copy_from_user(tmp, buf, count))
+ tmp = memdup_user(buf, count);
+ if (IS_ERR(tmp)) {
+ ret = PTR_ERR(tmp);
goto out;
+ }
ret = ppc_md.nvram_write(tmp, count, ppos);
-out:
kfree(tmp);
+out:
return ret;
-
}
static long dev_nvram_ioctl(struct file *file, unsigned int cmd,