Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

procfs: fix some wrong error code usage

[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>

authored by

Jovi Zhang and committed by
Linus Torvalds
fc3d8767 0db0c01b

+5 -2
+5 -2
fs/proc/base.c
··· 775 775 if (!task) 776 776 goto out_no_task; 777 777 778 - if (check_mem_permission(task)) 778 + ret = check_mem_permission(task); 779 + if (ret) 779 780 goto out; 780 781 781 782 ret = -ENOMEM; ··· 846 845 if (!task) 847 846 goto out_no_task; 848 847 849 - if (check_mem_permission(task)) 848 + copied = check_mem_permission(task); 849 + if (copied) 850 850 goto out; 851 851 852 852 copied = -ENOMEM; ··· 919 917 if (!task) 920 918 goto out_no_task; 921 919 920 + ret = -EPERM; 922 921 if (!ptrace_may_access(task, PTRACE_MODE_READ)) 923 922 goto out; 924 923