kernfs: fix regression in kernfs_fop_write caused by wrong type
authorIvan Vecera <ivecera@redhat.com>
Fri, 19 Jan 2018 08:18:54 +0000 (09:18 +0100)
committerAl Viro <viro@zeniv.linux.org.uk>
Fri, 19 Jan 2018 17:19:13 +0000 (12:19 -0500)
Commit b7ce40cff0b9 ("kernfs: cache atomic_write_len in
kernfs_open_file") changes type of local variable 'len' from ssize_t
to size_t. This change caused that the *ppos value is updated also
when the previous write callback failed.

Mentioned snippet:
...
len = ops->write(...); <- return value can be negative
...
if (len > 0)           <- true here in this case
        *ppos += len;
...

Fixes: b7ce40cff0b9 ("kernfs: cache atomic_write_len in kernfs_open_file")
Acked-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Ivan Vecera <ivecera@redhat.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/kernfs/file.c

index 9698e51656b10b52c7aafccb4a1d5d545eb9acba..d8f49c412f508d38cbde1487b14d43d88e964063 100644 (file)
@@ -275,7 +275,7 @@ static ssize_t kernfs_fop_write(struct file *file, const char __user *user_buf,
 {
        struct kernfs_open_file *of = kernfs_of(file);
        const struct kernfs_ops *ops;
-       size_t len;
+       ssize_t len;
        char *buf;
 
        if (of->atomic_write_len) {