Skip to content

Commit

Permalink
net/atm: fix proc_mpc_write incorrect return value
Browse files Browse the repository at this point in the history
[ Upstream commit d8bde3b ]

Then the input contains '\0' or '\n', proc_mpc_write has read them,
so the return value needs +1.

Fixes: 1da177e ("Linux-2.6.12-rc2")
Signed-off-by: Xiaobo Liu <cppcoffee@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
cppcoffee authored and gregkh committed Oct 29, 2022
1 parent fd66e30 commit 255ff20
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion net/atm/mpoa_proc.c
Expand Up @@ -219,11 +219,12 @@ static ssize_t proc_mpc_write(struct file *file, const char __user *buff,
if (!page)
return -ENOMEM;

for (p = page, len = 0; len < nbytes; p++, len++) {
for (p = page, len = 0; len < nbytes; p++) {
if (get_user(*p, buff++)) {
free_page((unsigned long)page);
return -EFAULT;
}
len += 1;
if (*p == '\0' || *p == '\n')
break;
}
Expand Down

0 comments on commit 255ff20

Please sign in to comment.