The patch titled sysfs: fix error handling in binattr write() has been added to the -mm tree. Its filename is sysfs-fix-error-handling-in-binattr-write.patch *** Remember to use Documentation/SubmitChecklist when testing your code *** See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find out what to do about this ------------------------------------------------------ Subject: sysfs: fix error handling in binattr write() From: Tejun Heo <htejun@xxxxxxxxx> Error handling in fs/sysfs/bin.c:write() was wrong because size_t count is used to receive return value from flush_write() which is negative on failure. This patch updates write() such that int variable is used instead. read() is updated the same way for consistency. Signed-off-by: Tejun Heo <htejun@xxxxxxxxx> Cc: Cornelia Huck <cornelia.huck@xxxxxxxxxx> Cc: Dipankar Sarma <dipankar@xxxxxxxxxx> Cc: Maneesh Soni <maneesh@xxxxxxxxxx> Cc: Greg KH <greg@xxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- fs/sysfs/bin.c | 21 ++++++++------------- 1 files changed, 8 insertions(+), 13 deletions(-) diff -puN fs/sysfs/bin.c~sysfs-fix-error-handling-in-binattr-write fs/sysfs/bin.c --- a/fs/sysfs/bin.c~sysfs-fix-error-handling-in-binattr-write +++ a/fs/sysfs/bin.c @@ -33,16 +33,13 @@ fill_read(struct dentry *dentry, char *b } static ssize_t -read(struct file * file, char __user * userbuf, size_t count, loff_t * off) +read(struct file *file, char __user *userbuf, size_t bytes, loff_t *off) { char *buffer = file->private_data; struct dentry *dentry = file->f_path.dentry; int size = dentry->d_inode->i_size; loff_t offs = *off; - int ret; - - if (count > PAGE_SIZE) - count = PAGE_SIZE; + int count = min_t(size_t, bytes, PAGE_SIZE); if (size) { if (offs > size) @@ -51,10 +48,9 @@ read(struct file * file, char __user * u count = size - offs; } - ret = fill_read(dentry, buffer, offs, count); - if (ret < 0) - return ret; - count = ret; + count = fill_read(dentry, buffer, offs, count); + if (count < 0) + return count; if (copy_to_user(userbuf, buffer, count)) return -EFAULT; @@ -78,16 +74,15 @@ flush_write(struct dentry *dentry, char return attr->write(kobj, buffer, offset, count); } -static ssize_t write(struct file * file, const char __user * userbuf, - size_t count, loff_t * off) +static ssize_t write(struct file *file, const char __user *userbuf, + size_t bytes, loff_t *off) { char *buffer = file->private_data; struct dentry *dentry = file->f_path.dentry; int size = dentry->d_inode->i_size; loff_t offs = *off; + int count = min_t(size_t, bytes, PAGE_SIZE); - if (count > PAGE_SIZE) - count = PAGE_SIZE; if (size) { if (offs > size) return 0; _ Patches currently in -mm which might be from htejun@xxxxxxxxx are origin.patch revert-gregkh-driver-sysfs-crash-debugging.patch sysfs-fix-i_ino-handling-in-sysfs.patch sysfs-fix-error-handling-in-binattr-write.patch sysfs-move-release_sysfs_dirent-to-dirc.patch sysfs-flatten-cleanup-paths-in-sysfs_add_link-and-create_dir.patch sysfs-consolidate-sysfs_dirent-creation-functions.patch sysfs-add-sysfs_dirent-s_parent.patch sysfs-add-sysfs_dirent-s_name.patch sysfs-make-sysfs_dirent-s_element-a-union.patch sysfs-implement-kobj_sysfs_assoc_lock.patch sysfs-reimplement-symlink-using-sysfs_dirent-tree.patch sysfs-implement-bin_buffer.patch sysfs-implement-sysfs_dirent-active-reference-and-immediate-disconnect.patch sysfs-kill-attribute-file-orphaning.patch sysfs-kill-unnecessary-attribute-owner.patch sysfs-kill-unnecessary-attribute-owner-fix.patch git-libata-all.patch sata_nv-add-back-some-verbosity-into-adma-error_handler.patch optional-led-trigger-for-libata.patch drivers-ata-pata_cmd640c-fix-build-with-config_pm=n.patch git-scsi-misc.patch introduce-config_has_dma.patch - To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html