aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorMatthew Wilcox (Oracle) <willy@infradead.org>2020-10-03 03:55:23 +0100
committerAl Viro <viro@zeniv.linux.org.uk>2020-10-15 14:20:42 -0400
commit7b84b665c874f60d84547635341e418f20cbbab2 (patch)
tree68a8569904410301bbeb6567788a2882d144b504 /fs
parentfs: Allow a NULL pos pointer to __kernel_write (diff)
downloadlinux-dev-7b84b665c874f60d84547635341e418f20cbbab2.tar.xz
linux-dev-7b84b665c874f60d84547635341e418f20cbbab2.zip
fs: Allow a NULL pos pointer to __kernel_read
Match the behaviour of new_sync_read() and __kernel_write(). Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs')
-rw-r--r--fs/read_write.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/fs/read_write.c b/fs/read_write.c
index 516eb51af70e..498cc00f3c08 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -449,11 +449,12 @@ ssize_t __kernel_read(struct file *file, void *buf, size_t count, loff_t *pos)
return warn_unsupported(file, "read");
init_sync_kiocb(&kiocb, file);
- kiocb.ki_pos = *pos;
+ kiocb.ki_pos = pos ? *pos : 0;
iov_iter_kvec(&iter, READ, &iov, 1, iov.iov_len);
ret = file->f_op->read_iter(&kiocb, &iter);
if (ret > 0) {
- *pos = kiocb.ki_pos;
+ if (pos)
+ *pos = kiocb.ki_pos;
fsnotify_access(file);
add_rchar(current, ret);
}