Skip to content

Commit

Permalink
procfs: fix some wrong error code usage
Browse files Browse the repository at this point in the history
[root@wei 1]# cat /proc/1/mem
cat: /proc/1/mem: No such process

error code -ESRCH is wrong in this situation.  Return -EPERM instead.

Signed-off-by: Jovi Zhang <bookjovi@gmail.com>
Reviewed-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Jovi Zhang authored and Linus Torvalds committed Mar 24, 2011
1 parent 0db0c01 commit fc3d876
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions fs/proc/base.c
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,8 @@ static ssize_t mem_read(struct file * file, char __user * buf,
if (!task)
goto out_no_task;

if (check_mem_permission(task))
ret = check_mem_permission(task);
if (ret)
goto out;

ret = -ENOMEM;
Expand Down Expand Up @@ -845,7 +846,8 @@ static ssize_t mem_write(struct file * file, const char __user *buf,
if (!task)
goto out_no_task;

if (check_mem_permission(task))
copied = check_mem_permission(task);
if (copied)
goto out;

copied = -ENOMEM;
Expand Down Expand Up @@ -917,6 +919,7 @@ static ssize_t environ_read(struct file *file, char __user *buf,
if (!task)
goto out_no_task;

ret = -EPERM;
if (!ptrace_may_access(task, PTRACE_MODE_READ))
goto out;

Expand Down

0 comments on commit fc3d876

Please sign in to comment.