]> git.proxmox.com Git - mirror_iproute2.git/commit
lib/fs: Fix single return points for get_cgroup2_*
authorAndrea Claudi <aclaudi@redhat.com>
Mon, 22 Feb 2021 18:14:32 +0000 (19:14 +0100)
committerStephen Hemminger <stephen@networkplumber.org>
Tue, 23 Feb 2021 02:20:44 +0000 (18:20 -0800)
commitb2d44b9a95270203dd3c2adb38f6c4ba549d4196
treeee0cc30e901f3591a5dbbb4910ec23b41dd89070
parent1de363b1800c371037ff2b2a6c1004627e58f68e
lib/fs: Fix single return points for get_cgroup2_*

Functions get_cgroup2_id() and get_cgroup2_path() may call close() with
a negative argument.
Avoid that making the calls conditional on the file descriptors.

get_cgroup2_path() may also return NULL leaking a file descriptor.
Ensure this does not happen using a single return point.

Fixes: d5e6ee0dac64 ("ss: introduce cgroup2 cache and helper functions")
Fixes: 8f1cd119b377 ("lib: fix checking of returned file handle size for cgroup")
Signed-off-by: Andrea Claudi <aclaudi@redhat.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
lib/fs.c