libfs: return error code on failed attr set
PATCH 1/1 libfs: return error code on failed attr set
Currently all simple_attr.set handlers return 0 on success and negative codes on error. Fix simple_attr_write() to return these error codes.
--- fs/libfs.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
fs/libfs.c +3 -2
@@ -822,10 +822,11 @@ ssize_t simple_attr_write(struct file *fif (copy_from_user (attr->set_buf, buf, size)) goto out; - ret = len;/* claim we got the whole input */ attr->set_buf[size] ='\0' ; val =simple_strtol (attr->set_buf,NULL ,0 ); - attr->set (attr->data, val); + ret = attr->set (attr->data, val); +if (ret ==0 ) + ret = len;/* on success, claim we got the whole input */ out:mutex_unlock (&attr->mutex);return ret;
Quoted 2 lines · Wu Fengguang
Currently all simple_attr.set handlers return 0 on success and negative codes on error. Fix
simple_attr_write()to return these error codes.
Looks good to me assuming you actually audited all the implementations to do the right thing.
Quoted 6 lines · Christoph Hellwig
Quoted 2 lines · Wu Fengguang
Currently all simple_attr.set handlers return 0 on success and negative codes on error. Fix
simple_attr_write()to return these error codes.Looks good to me assuming you actually audited all the implementations to do the right thing.
Yes I checked all DEFINE_SIMPLE_ATTRIBUTE users. All the _set() handlers returns 0 for success and negative error code for failure.
Thanks,
Fengguang