diff options
Diffstat (limited to 'fs/sysfs/file.c')
-rw-r--r-- | fs/sysfs/file.c | 8 |
1 files changed, 7 insertions, 1 deletions
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, | |||
114 | * If buf != of->prealloc_buf, we don't know how | 114 | * If buf != of->prealloc_buf, we don't know how |
115 | * large it is, so cannot safely pass it to ->show | 115 | * large it is, so cannot safely pass it to ->show |
116 | */ | 116 | */ |
117 | if (pos || WARN_ON_ONCE(buf != of->prealloc_buf)) | 117 | if (WARN_ON_ONCE(buf != of->prealloc_buf)) |
118 | return 0; | 118 | return 0; |
119 | len = ops->show(kobj, of->kn->priv, buf); | 119 | len = ops->show(kobj, of->kn->priv, buf); |
120 | if (pos) { | ||
121 | if (len <= pos) | ||
122 | return 0; | ||
123 | len -= pos; | ||
124 | memmove(buf, buf + pos, len); | ||
125 | } | ||
120 | return min(count, len); | 126 | return min(count, len); |
121 | } | 127 | } |
122 | 128 | ||