kernfs: fix regression in kernfs_fop_write caused by wrong type
commit8d94a30179cad987694a23a6442d27efaed5fa9e
authorIvan Vecera <ivecera@redhat.com>
Fri, 19 Jan 2018 08:18:54 +0000 (19 09:18 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 16 Feb 2018 19:06:47 +0000 (16 20:06 +0100)
treed536cde570836bbb40ebb67245f320ad92afca3f
parent0e61f8b07b5795f93f45c437f26fa48ed48b538c
kernfs: fix regression in kernfs_fop_write caused by wrong type

commit ba87977a49913129962af8ac35b0e13e0fa4382d upstream.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/kernfs/file.c