kernfs: fix regression in kernfs_fop_write caused by wrong type
"Linux Kernel Mailing List" <[email protected]>
| Newsgroups | gmane.linux.kernel.commits.head |
|---|---|
| Message-ID | <[email protected]> |
Web: https://git.kernel.org/torvalds/c/ba87977a49913129962af8ac35b0e13e0fa4382d Commit: ba87977a49913129962af8ac35b0e13e0fa4382d Parent: ce4bb04cae8924792ed92f4af2793b77fc986f0e Refname: refs/heads/master Author: Ivan Vecera <[email protected]> AuthorDate: Fri Jan 19 09:18:54 2018 +0100 Committer: Al Viro <[email protected]> CommitDate: Fri Jan 19 12:19:13 2018 -0500 kernfs: fix regression in kernfs_fop_write caused by wrong type 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 <[email protected]> Signed-off-by: Ivan Vecera <[email protected]> Signed-off-by: Al Viro <[email protected]> --- fs/kernfs/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/kernfs/file.c b/fs/kernfs/file.c index 9698e51656b1..d8f49c412f50 100644 --- a/fs/kernfs/file.c +++ b/fs/kernfs/file.c @@ -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) { -- To unsubscribe from this list: send the line "unsubscribe git-commits-head" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html