]> git.baikalelectronics.ru Git - kernel.git/commitdiff
net/atm: fix proc_mpc_write incorrect return value
authorXiaobo Liu <cppcoffee@gmail.com>
Fri, 14 Oct 2022 02:05:40 +0000 (10:05 +0800)
committerDavid S. Miller <davem@davemloft.net>
Sat, 15 Oct 2022 10:08:36 +0000 (11:08 +0100)
Then the input contains '\0' or '\n', proc_mpc_write has read them,
so the return value needs +1.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Xiaobo Liu <cppcoffee@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/atm/mpoa_proc.c

index 829db9eba0cb95ac9cfe775e8eaad712943a8dbe..aaf64b953915070be8501d8a7a7a40d9def67234 100644 (file)
@@ -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;
        }