Commit 82244b16 authored by Oliver Neukum's avatar Oliver Neukum Committed by Greg Kroah-Hartman

sysfs: error handling in sysfs, fill_read_buffer()

if a driver returns an error in fill_read_buffer(), the buffer will be
marked as filled. Subsequent reads will return eof. But there is
no data because of an error, not because it has been read.
Not marking the buffer filled is the obvious fix.
Signed-off-by: default avatarOliver Neukum <oliver@neukum.name>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent b067db49
...@@ -83,7 +83,8 @@ remove_from_collection(struct sysfs_buffer *buffer, struct inode *node) ...@@ -83,7 +83,8 @@ remove_from_collection(struct sysfs_buffer *buffer, struct inode *node)
* Allocate @buffer->page, if it hasn't been already, then call the * Allocate @buffer->page, if it hasn't been already, then call the
* kobject's show() method to fill the buffer with this attribute's * kobject's show() method to fill the buffer with this attribute's
* data. * data.
* This is called only once, on the file's first read. * This is called only once, on the file's first read unless an error
* is returned.
*/ */
static int fill_read_buffer(struct dentry * dentry, struct sysfs_buffer * buffer) static int fill_read_buffer(struct dentry * dentry, struct sysfs_buffer * buffer)
{ {
...@@ -101,12 +102,13 @@ static int fill_read_buffer(struct dentry * dentry, struct sysfs_buffer * buffer ...@@ -101,12 +102,13 @@ static int fill_read_buffer(struct dentry * dentry, struct sysfs_buffer * buffer
buffer->event = atomic_read(&sd->s_event); buffer->event = atomic_read(&sd->s_event);
count = ops->show(kobj,attr,buffer->page); count = ops->show(kobj,attr,buffer->page);
buffer->needs_read_fill = 0;
BUG_ON(count > (ssize_t)PAGE_SIZE); BUG_ON(count > (ssize_t)PAGE_SIZE);
if (count >= 0) if (count >= 0) {
buffer->needs_read_fill = 0;
buffer->count = count; buffer->count = count;
else } else {
ret = count; ret = count;
}
return ret; return ret;
} }
......
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