Implement ->proc_write_buf() so procfs copies in what is written to /proc/srm_environment/* before it pins the entry, and hand that copy to the console callback through the page it used before.
Signed-off-by: Christian Brauner (Amutable) <[email protected]> --- arch/alpha/kernel/srm_env.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/arch/alpha/kernel/srm_env.c b/arch/alpha/kernel/srm_env.c index faafc2df7886..6a1742b09a82 100644 --- a/arch/alpha/kernel/srm_env.c +++ b/arch/alpha/kernel/srm_env.c @@ -81,7 +81,7 @@ static int srm_env_proc_show(struct seq_file *m, void *v) return ret; } -static ssize_t srm_env_proc_write(struct file *file, const char __user *buffer, +static ssize_t srm_env_proc_write(struct file *file, char *buffer, size_t count, loff_t *pos) { int res; @@ -92,13 +92,8 @@ static ssize_t srm_env_proc_write(struct file *file, const char __user *buffer, if (!buf) return -ENOMEM; - res = -EINVAL; - if (count >= PAGE_SIZE) - goto out; - res = -EFAULT; - if (copy_from_user(buf, buffer, count)) - goto out; + memcpy(buf, buffer, count); buf[count] = '\0'; ret1 = callback_setenv(id, buf, count); @@ -109,14 +104,13 @@ static ssize_t srm_env_proc_write(struct file *file, const char __user *buffer, res = (int) ret1; } - out: free_page((unsigned long)buf); return res; } static const struct proc_ops srm_env_proc_ops = { .proc_show = srm_env_proc_show, - .proc_write = srm_env_proc_write, + .proc_write_buf = srm_env_proc_write, }; static int __init -- 2.53.0
