summaryrefslogtreecommitdiffstats
path: root/fs/sysfs/file.c
diff options
context:
space:
mode:
authorIngo Molnar <mingo@kernel.org>2017-04-11 09:05:36 +0200
committerIngo Molnar <mingo@kernel.org>2017-04-11 09:05:36 +0200
commit36a4dfc37856cae40e4d864950f768d8b7d4f9f5 (patch)
tree3aa6a1459a699b986632f64b740e8e98e3ce6500 /fs/sysfs/file.c
parenta481db34b9beb7a9647c23f2320dd38a2b1d681f (diff)
parent39da7c509acff13fc8cb12ec1bb20337c988ed36 (diff)
downloadlinux-36a4dfc37856cae40e4d864950f768d8b7d4f9f5.tar.bz2
Merge tag 'v4.11-rc6' into sched/core, to pick up fixes
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'fs/sysfs/file.c')
-rw-r--r--fs/sysfs/file.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
index b803213d1307..39c75a86c67f 100644
--- a/fs/sysfs/file.c
+++ b/fs/sysfs/file.c
@@ -108,7 +108,7 @@ 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;
+ ssize_t len;
/*
* If buf != of->prealloc_buf, we don't know how
@@ -117,13 +117,15 @@ static ssize_t sysfs_kf_read(struct kernfs_open_file *of, char *buf,
if (WARN_ON_ONCE(buf != of->prealloc_buf))
return 0;
len = ops->show(kobj, of->kn->priv, buf);
+ if (len < 0)
+ return len;
if (pos) {
if (len <= pos)
return 0;
len -= pos;
memmove(buf, buf + pos, len);
}
- return min(count, len);
+ return min_t(ssize_t, count, len);
}
/* kernfs write callback for regular sysfs files */