diff options
author | Ming Lei <ming.lei@canonical.com> | 2013-10-23 09:44:53 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-10-25 00:46:27 -0400 |
commit | b9c0622516b73170fa9abffece3079920b78ed6f (patch) | |
tree | 1e106a616c8ca1fda0f316b6207ff3612762c143 | |
parent | 0cba7de7f6cdcf84c9b75d29041c475aedeb45c9 (diff) |
sysfs: fix sysfs_write_file for bin file
Before patch(sysfs: prepare path write for unified regular / bin
file handling), when size of bin file is zero, writting still can
continue, but this patch changes the behaviour.
The worse thing is that firmware loader is broken by this patch,
and user space application can't write to firmware bin file any more
because both firmware loader and drivers can't know at advance how
large the firmware file is and have to set its initialized size as
zero.
This patch fixes the problem and keeps behaviour of writting to bin
as before.
Reported-by: Lothar Waßmann <LW@karo-electronics.de>
Tested-by: Lothar Waßmann <LW@karo-electronics.de>
Acked-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Ming Lei <ming.lei@canonical.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | fs/sysfs/file.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c index 5d818df7250b..c3795978b404 100644 --- a/fs/sysfs/file.c +++ b/fs/sysfs/file.c | |||
@@ -275,11 +275,10 @@ static ssize_t sysfs_write_file(struct file *file, const char __user *user_buf, | |||
275 | { | 275 | { |
276 | struct sysfs_open_file *of = sysfs_of(file); | 276 | struct sysfs_open_file *of = sysfs_of(file); |
277 | ssize_t len = min_t(size_t, count, PAGE_SIZE); | 277 | ssize_t len = min_t(size_t, count, PAGE_SIZE); |
278 | loff_t size = file_inode(file)->i_size; | ||
278 | char *buf; | 279 | char *buf; |
279 | 280 | ||
280 | if (sysfs_is_bin(of->sd)) { | 281 | if (sysfs_is_bin(of->sd) && size) { |
281 | loff_t size = file_inode(file)->i_size; | ||
282 | |||
283 | if (size <= *ppos) | 282 | if (size <= *ppos) |
284 | return 0; | 283 | return 0; |
285 | len = min_t(ssize_t, len, size - *ppos); | 284 | len = min_t(ssize_t, len, size - *ppos); |