summaryrefslogtreecommitdiffstats
path: root/fs/sysfs/file.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/sysfs/file.c')
-rw-r--r--fs/sysfs/file.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
index 5d818df..c379597 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,
{
struct sysfs_open_file *of = sysfs_of(file);
ssize_t len = min_t(size_t, count, PAGE_SIZE);
+ loff_t size = file_inode(file)->i_size;
char *buf;
- if (sysfs_is_bin(of->sd)) {
- loff_t size = file_inode(file)->i_size;
-
+ if (sysfs_is_bin(of->sd) && size) {
if (size <= *ppos)
return 0;
len = min_t(ssize_t, len, size - *ppos);
OpenPOWER on IntegriCloud