X-Git-Url: http://git.cascardo.info/?a=blobdiff_plain;f=fs%2Fsysfs%2Ffile.c;h=b803213d1307e9137c3bfe5e04ee4ac5bd396cce;hb=e7c5412f77ac41ff14873f445bce0db4fef5890c;hp=f35523d4fa3a6d657260e7b04d5273db2dcd53b1;hpb=f2777c1344ea7ce9ae3dd8f61166e3ad8b2a5962;p=cascardo%2Flinux.git diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c index f35523d4fa3a..b803213d1307 100644 --- a/fs/sysfs/file.c +++ b/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); }