diff options
author | YueHaibing <yuehaibing@huawei.com> | 2022-11-05 19:06:11 +0800 |
---|---|---|
committer | Andrew Morton <akpm@linux-foundation.org> | 2022-11-18 13:55:09 -0800 |
commit | 333d073dee3a6865171d43e3b0a9ff688bff5891 (patch) | |
tree | d26b3c2ff8344c44afb654698a7de9ca06177930 | |
parent | d51cf40d38cb58575eca75481fb851bf3a348d78 (diff) | |
download | linux-stable-333d073dee3a6865171d43e3b0a9ff688bff5891.tar.gz linux-stable-333d073dee3a6865171d43e3b0a9ff688bff5891.tar.bz2 linux-stable-333d073dee3a6865171d43e3b0a9ff688bff5891.zip |
selftests: cgroup: fix unsigned comparison with less than zero
'size' is unsigned, it never less than zero.
Link: https://lkml.kernel.org/r/20221105110611.28920-1-yuehaibing@huawei.com
Fixes: 6c26df84e1f2 ("selftests: cgroup: return -errno from cg_read()/cg_write() on failure")
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Reviewed-by: Yosry Ahmed <yosryahmed@google.com>
Acked-by: Roman Gushchin <roman.gushchin@linux.dev>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Cc: David Rientjes <rientjes@google.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Shakeel Butt <shakeelb@google.com>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Tejun Heo <tj@kernel.org>
Cc: zefan li <lizefan.x@bytedance.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
-rw-r--r-- | tools/testing/selftests/cgroup/cgroup_util.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/tools/testing/selftests/cgroup/cgroup_util.c b/tools/testing/selftests/cgroup/cgroup_util.c index 4c52cc6f2f9c..e8bbbdb77e0d 100644 --- a/tools/testing/selftests/cgroup/cgroup_util.c +++ b/tools/testing/selftests/cgroup/cgroup_util.c @@ -555,6 +555,7 @@ int proc_mount_contains(const char *option) ssize_t proc_read_text(int pid, bool thread, const char *item, char *buf, size_t size) { char path[PATH_MAX]; + ssize_t ret; if (!pid) snprintf(path, sizeof(path), "/proc/%s/%s", @@ -562,8 +563,8 @@ ssize_t proc_read_text(int pid, bool thread, const char *item, char *buf, size_t else snprintf(path, sizeof(path), "/proc/%d/%s", pid, item); - size = read_text(path, buf, size); - return size < 0 ? -1 : size; + ret = read_text(path, buf, size); + return ret < 0 ? -1 : ret; } int proc_read_strstr(int pid, bool thread, const char *item, const char *needle) |