summaryrefslogtreecommitdiffstats
path: root/fs/configfs/file.c
diff options
context:
space:
mode:
authorTal Shorer <tal.shorer@gmail.com>2016-07-01 12:28:57 +0300
committerChristoph Hellwig <hch@lst.de>2016-07-10 21:02:18 +0900
commit3dc3afadeb0403fd967b97ee282ab9053d36da2b (patch)
tree2d9095867f2272e11ac0831e4d312811220d84d6 /fs/configfs/file.c
parentee40fb2948fc99096836995d4f3ddcc0efbac790 (diff)
downloadlinux-3dc3afadeb0403fd967b97ee282ab9053d36da2b.tar.bz2
configfs: don't set buffer_needs_fill to zero if show() returns error
A confgifs attribute's show() callback is called once the first time the user attempts to read from it. If it returns an error, that error is returned to the user. However, the open file's buffer_needs_fill is still set to zero and consecutive read() calls will find an empty buffer that doesn't need filling and return 0 to the user. This could give the user the wrong impression that the attribute was read successfully. Fix this by not setting buffer_needs_fill if show() returns an error, making consecutive read() calls call show() again and either get an error again or get data. Signed-off-by: Tal Shorer <tal.shorer@gmail.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'fs/configfs/file.c')
-rw-r--r--fs/configfs/file.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/fs/configfs/file.c b/fs/configfs/file.c
index bbc1252a59f5..c30cf49b69d2 100644
--- a/fs/configfs/file.c
+++ b/fs/configfs/file.c
@@ -80,11 +80,11 @@ static int fill_read_buffer(struct dentry * dentry, struct configfs_buffer * buf
count = attr->show(item, buffer->page);
- buffer->needs_read_fill = 0;
BUG_ON(count > (ssize_t)SIMPLE_ATTR_SIZE);
- if (count >= 0)
+ if (count >= 0) {
+ buffer->needs_read_fill = 0;
buffer->count = count;
- else
+ } else
ret = count;
return ret;
}