summaryrefslogtreecommitdiffstats
path: root/kernel/fs/sysfs/file.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/fs/sysfs/file.c')
-rw-r--r--kernel/fs/sysfs/file.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/kernel/fs/sysfs/file.c b/kernel/fs/sysfs/file.c
index f35523d4f..b803213d1 100644
--- a/kernel/fs/sysfs/file.c
+++ b/kernel/fs/sysfs/file.c
@@ -114,9 +114,15 @@ static ssize_t sysfs_kf_read(struct kernfs_open_file *of, char *buf,
* If buf != of->prealloc_buf, we don't know how
* large it is, so cannot safely pass it to ->show
*/
- if (pos || WARN_ON_ONCE(buf != of->prealloc_buf))
+ if (WARN_ON_ONCE(buf != of->prealloc_buf))
return 0;
len = ops->show(kobj, of->kn->priv, buf);
+ if (pos) {
+ if (len <= pos)
+ return 0;
+ len -= pos;
+ memmove(buf, buf + pos, len);
+ }
return min(count, len);
}