diff options
| author | Greg Kroah-Hartman <gregkh@suse.de> | 2009-01-20 18:51:16 -0500 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@suse.de> | 2009-01-20 23:52:09 -0500 |
| commit | 4503efd0891c40e30928afb4b23dc3f99c62a6b2 (patch) | |
| tree | b92d71b333e30f90b4a91a4e4bea895f5489a6ae | |
| parent | 72638f598ec9f05a43fcb22dc1dd8dc34c43acc1 (diff) | |
sysfs: fix problems with binary files
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@gnu.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
| -rw-r--r-- | fs/sysfs/bin.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/fs/sysfs/bin.c b/fs/sysfs/bin.c index 66f6e58a7e4b..f2c478c3424e 100644 --- a/fs/sysfs/bin.c +++ b/fs/sysfs/bin.c | |||
| @@ -63,6 +63,9 @@ read(struct file *file, char __user *userbuf, size_t bytes, loff_t *off) | |||
| 63 | int count = min_t(size_t, bytes, PAGE_SIZE); | 63 | int count = min_t(size_t, bytes, PAGE_SIZE); |
| 64 | char *temp; | 64 | char *temp; |
| 65 | 65 | ||
| 66 | if (!bytes) | ||
| 67 | return 0; | ||
| 68 | |||
| 66 | if (size) { | 69 | if (size) { |
| 67 | if (offs > size) | 70 | if (offs > size) |
| 68 | return 0; | 71 | return 0; |
| @@ -131,6 +134,9 @@ static ssize_t write(struct file *file, const char __user *userbuf, | |||
| 131 | int count = min_t(size_t, bytes, PAGE_SIZE); | 134 | int count = min_t(size_t, bytes, PAGE_SIZE); |
| 132 | char *temp; | 135 | char *temp; |
| 133 | 136 | ||
| 137 | if (!bytes) | ||
| 138 | return 0; | ||
| 139 | |||
| 134 | if (size) { | 140 | if (size) { |
| 135 | if (offs > size) | 141 | if (offs > size) |
| 136 | return 0; | 142 | return 0; |
