]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - fs/sysfs/file.c
sysfs: fix sysfs_write_file for bin file
[karo-tx-linux.git] / fs / sysfs / file.c
index 5d818df7250b9bae06beb67b17c70c3d8f39d8ef..c3795978b40452772f3dae70194676533bcf9832 100644 (file)
@@ -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);