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
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 <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
cppcoffee authored and davem330 committed Oct 15, 2022
1 parent a8aed7b commit d8bde3b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion net/atm/mpoa_proc.c
Original file line number Diff line number Diff line change
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 d8bde3b

Please sign in to comment.