diff options
author | Alex Shi <alex.shi@linaro.org> | 2016-09-19 17:39:02 +0800 |
---|---|---|
committer | Alex Shi <alex.shi@linaro.org> | 2016-09-19 17:39:02 +0800 |
commit | 7acaa1968831591b5cf97b6cb00b0acca2dc5ee1 (patch) | |
tree | 9dba673061452165322aa9d9c8493ce90e33a651 /fs/sysfs/file.c | |
parent | b71d24fd9283d80a2ca7b26cdd5de296b17de72c (diff) | |
parent | 7ddc655ad909372848a3e7995e222c2b9224c2e0 (diff) |
Merge branch 'linux-linaro-lsk-v4.1' into linux-linaro-lsk-v4.1-rtlsk-v4.1-16.09-rt
Diffstat (limited to 'fs/sysfs/file.c')
-rw-r--r-- | fs/sysfs/file.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c index 7c2867b44141..167f80e8f08d 100644 --- a/fs/sysfs/file.c +++ b/fs/sysfs/file.c @@ -108,14 +108,22 @@ static ssize_t sysfs_kf_read(struct kernfs_open_file *of, char *buf, { const struct sysfs_ops *ops = sysfs_file_ops(of->kn); struct kobject *kobj = of->kn->parent->priv; + size_t len; /* * 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; - return ops->show(kobj, of->kn->priv, buf); + 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); } /* kernfs write callback for regular sysfs files */ |