From: Dmitry Yakunin Date: Sun, 5 Jul 2020 16:18:12 +0000 (+0300) Subject: lib: fix checking of returned file handle size for cgroup X-Git-Tag: v5.8.0~22 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8f1cd119b3772be25e1ac6f017006012bd5a4541;p=thirdparty%2Fiproute2.git lib: fix checking of returned file handle size for cgroup Before this patch check is happened only in case when we try to find cgroup at cgroup2 mount point. v2: - add Fixes line before Signed-off-by (David Ahern) Fixes: d5e6ee0dac64 ("ss: introduce cgroup2 cache and helper functions") Signed-off-by: Dmitry Yakunin Signed-off-by: Stephen Hemminger --- diff --git a/lib/fs.c b/lib/fs.c index e265fc04e..4b90a7046 100644 --- a/lib/fs.c +++ b/lib/fs.c @@ -148,10 +148,10 @@ __u64 get_cgroup2_id(const char *path) strerror(errno)); goto out; } - if (fhp->handle_bytes != sizeof(__u64)) { - fprintf(stderr, "Invalid size of cgroup2 ID\n"); - goto out; - } + } + if (fhp->handle_bytes != sizeof(__u64)) { + fprintf(stderr, "Invalid size of cgroup2 ID\n"); + goto out; } memcpy(cg_id.bytes, fhp->f_handle, sizeof(__u64));