Skip to content

Commit 2b88c49

Browse files
YueHaibingkelsey-steele
authored andcommitted
selftests: cgroup: fix unsigned comparison with less than zero
[ Upstream commit 333d073 ] 'size' is unsigned, it never less than zero. Link: https://lkml.kernel.org/r/[email protected] Fixes: 6c26df8 ("selftests: cgroup: return -errno from cg_read()/cg_write() on failure") Signed-off-by: YueHaibing <[email protected]> Reviewed-by: Yosry Ahmed <[email protected]> Acked-by: Roman Gushchin <[email protected]> Reviewed-by: Kamalesh Babulal <[email protected]> Cc: David Rientjes <[email protected]> Cc: Johannes Weiner <[email protected]> Cc: Shakeel Butt <[email protected]> Cc: Shuah Khan <[email protected]> Cc: Tejun Heo <[email protected]> Cc: zefan li <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Sasha Levin <[email protected]> [kms: backport to 5.15] Signed-off-by: Kelsey Steele <[email protected]>
1 parent d1c41b5 commit 2b88c49

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

tools/testing/selftests/cgroup/cgroup_util.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -531,15 +531,16 @@ int set_oom_adj_score(int pid, int score)
531531
ssize_t proc_read_text(int pid, bool thread, const char *item, char *buf, size_t size)
532532
{
533533
char path[PATH_MAX];
534+
ssize_t ret;
534535

535536
if (!pid)
536537
snprintf(path, sizeof(path), "/proc/%s/%s",
537538
thread ? "thread-self" : "self", item);
538539
else
539540
snprintf(path, sizeof(path), "/proc/%d/%s", pid, item);
540541

541-
size = read_text(path, buf, size);
542-
return size < 0 ? -1 : size;
542+
ret = read_text(path, buf, size);
543+
return ret < 0 ? -1 : ret;
543544
}
544545

545546
int proc_read_strstr(int pid, bool thread, const char *item, const char *needle)

0 commit comments

Comments
 (0)