Commit f1db1b80 authored by Ivan Vecera's avatar Ivan Vecera Committed by Greg Kroah-Hartman

kernfs: fix regression in kernfs_fop_write caused by wrong type

commit ba87977a upstream.

Commit b7ce40cf ("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: b7ce40cf ("kernfs: cache atomic_write_len in kernfs_open_file")
Acked-by: default avatarTejun Heo <tj@kernel.org>
Signed-off-by: default avatarIvan Vecera <ivecera@redhat.com>
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent fb8b1685
...@@ -272,7 +272,7 @@ static ssize_t kernfs_fop_write(struct file *file, const char __user *user_buf, ...@@ -272,7 +272,7 @@ static ssize_t kernfs_fop_write(struct file *file, const char __user *user_buf,
{ {
struct kernfs_open_file *of = kernfs_of(file); struct kernfs_open_file *of = kernfs_of(file);
const struct kernfs_ops *ops; const struct kernfs_ops *ops;
size_t len; ssize_t len;
char *buf; char *buf;
if (of->atomic_write_len) { if (of->atomic_write_len) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment