Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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.

Signed-off-by: Wu Fengguang <fengguang.wu@intel.com>
Cc: Theodore Ts'o <tytso@mit.edu>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Nick Piggin <npiggin@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

authored by

Wu Fengguang and committed by
Al Viro
05cc0cee 7a62cc10

+3 -2
+3 -2
fs/libfs.c
··· 739 739 if (copy_from_user(attr->set_buf, buf, size)) 740 740 goto out; 741 741 742 - ret = len; /* claim we got the whole input */ 743 742 attr->set_buf[size] = '\0'; 744 743 val = simple_strtol(attr->set_buf, NULL, 0); 745 - attr->set(attr->data, val); 744 + ret = attr->set(attr->data, val); 745 + if (ret == 0) 746 + ret = len; /* on success, claim we got the whole input */ 746 747 out: 747 748 mutex_unlock(&attr->mutex); 748 749 return ret;