[patch 09/43] sysfs: fix problems with binary files

From: Greg KH
Date: Fri Jan 30 2009 - 22:02:16 EST


2.6.28-stable review patch. If anyone has any objections, please let us know.

------------------

From: Greg Kroah-Hartman <gregkh@xxxxxxx>

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 <proski@xxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxx>

---
fs/sysfs/bin.c | 6 ++++++
1 file changed, 6 insertions(+)

--- a/fs/sysfs/bin.c
+++ b/fs/sysfs/bin.c
@@ -63,6 +63,9 @@ read(struct file *file, char __user *use
int count = min_t(size_t, bytes, PAGE_SIZE);
char *temp;

+ if (!bytes)
+ return 0;
+
if (size) {
if (offs > size)
return 0;
@@ -131,6 +134,9 @@ static ssize_t write(struct file *file,
int count = min_t(size_t, bytes, PAGE_SIZE);
char *temp;

+ if (!bytes)
+ return 0;
+
if (size) {
if (offs > size)
return 0;

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/