From: Greg Kroah-Hartman Date: Tue, 20 Jan 2009 23:51:16 +0000 (-0800) Subject: sysfs: fix problems with binary files X-Git-Tag: v2.6.27.14~27 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2085509e2715178a54cf23dc63f87cb2c58f3bf4;p=thirdparty%2Fkernel%2Fstable.git sysfs: fix problems with binary files commit 4503efd0891c40e30928afb4b23dc3f99c62a6b2 upstream. Some sysfs binary files don't like having 0 passed to them as a size. Fix this up at the root by just returning to the vfs if userspace asks us for a zero sized buffer. Thanks to Pavel Roskin for pointing this out. Reported-by: Pavel Roskin Signed-off-by: Greg Kroah-Hartman --- diff --git a/fs/sysfs/bin.c b/fs/sysfs/bin.c index 006fc64227ddb..aa244842f30b7 100644 --- a/fs/sysfs/bin.c +++ b/fs/sysfs/bin.c @@ -62,6 +62,9 @@ read(struct file *file, char __user *userbuf, size_t bytes, loff_t *off) loff_t offs = *off; int count = min_t(size_t, bytes, PAGE_SIZE); + if (!bytes) + return 0; + if (size) { if (offs > size) return 0; @@ -119,6 +122,9 @@ static ssize_t write(struct file *file, const char __user *userbuf, loff_t offs = *off; int count = min_t(size_t, bytes, PAGE_SIZE); + if (!bytes) + return 0; + if (size) { if (offs > size) return 0;