lkml.org 
[lkml]   [2018]   [Apr]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH 4/5] proc: simpler iterations for /proc/*/cmdline
On Wed, 21 Feb 2018 22:30:09 +0300 Alexey Dobriyan <adobriyan@gmail.com> wrote:

> "rv" variable is used both as a counter of bytes transferred and
> an error value holder but it can be reduced solely to error values
> if original start of userspace buffer is stashed and used at the very
> end.
>
> ...
>
> --- a/fs/proc/base.c
> +++ b/fs/proc/base.c
>
> ...
>
> @@ -371,12 +365,16 @@ static ssize_t proc_pid_cmdline_read(struct file *file, char __user *buf,
> }
> }
>
> +end:
> + free_page((unsigned long)page);
> + mmput(mm);
> + *pos += buf - buf0;
> + return buf - buf0;
> +
> out_free_page:
> free_page((unsigned long)page);
> out_mmput:
> mmput(mm);
> - if (rv > 0)
> - *pos += rv;
> return rv;
> }

(scratches head). Why not do this?

--- a/fs/proc/base.c~proc-simpler-iterations-for-proc-cmdline-fix
+++ a/fs/proc/base.c
@@ -363,11 +363,8 @@ static ssize_t proc_pid_cmdline_read(str
}

end:
- free_page((unsigned long)page);
- mmput(mm);
*pos += buf - buf0;
- return buf - buf0;
-
+ rv = buf - buf0;
out_free_page:
free_page((unsigned long)page);
out_mmput:
(and maybe rv should be ssize_t)

\
 
 \ /
  Last update: 2018-04-20 02:15    [W:0.189 / U:0.276 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site