diff options
author | Michal Koutný <mkoutny@suse.com> | 2022-08-26 18:52:37 +0200 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2022-08-26 10:57:41 -1000 |
commit | fa7e439cf90ba23ea473d0b7d85efd02ae6ccf94 (patch) | |
tree | 9361bef45e46f7ba7fd29ea16ca23405cfbfce97 /kernel/cgroup/cgroup.c | |
parent | 4534dee941056a4ab9dca4a9e2edff28692800b2 (diff) | |
download | linux-stable-fa7e439cf90ba23ea473d0b7d85efd02ae6ccf94.tar.gz linux-stable-fa7e439cf90ba23ea473d0b7d85efd02ae6ccf94.tar.bz2 linux-stable-fa7e439cf90ba23ea473d0b7d85efd02ae6ccf94.zip |
cgroup: Homogenize cgroup_get_from_id() return value
Cgroup id is user provided datum hence extend its return domain to
include possible error reason (similar to cgroup_get_from_fd()).
This change also fixes commit d4ccaf58a847 ("bpf: Introduce cgroup
iter") that would use NULL instead of proper error handling in
d4ccaf58a847 ("bpf: Introduce cgroup iter").
Additionally, neither of: fc_appid_store, bpf_iter_attach_cgroup,
mem_cgroup_get_from_ino (callers of cgroup_get_from_fd) is built without
CONFIG_CGROUPS (depends via CONFIG_BLK_CGROUP, direct, transitive
CONFIG_MEMCG respectively) transitive, so drop the singular definition
not needed with !CONFIG_CGROUPS.
Fixes: d4ccaf58a847 ("bpf: Introduce cgroup iter")
Signed-off-by: Michal Koutný <mkoutny@suse.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
Diffstat (limited to 'kernel/cgroup/cgroup.c')
-rw-r--r-- | kernel/cgroup/cgroup.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c index 3229f3558766..a8780ef3b769 100644 --- a/kernel/cgroup/cgroup.c +++ b/kernel/cgroup/cgroup.c @@ -6005,7 +6005,7 @@ void cgroup_path_from_kernfs_id(u64 id, char *buf, size_t buflen) /* * cgroup_get_from_id : get the cgroup associated with cgroup id * @id: cgroup id - * On success return the cgrp, on failure return NULL + * On success return the cgrp or ERR_PTR on failure * Only cgroups within current task's cgroup NS are valid. */ struct cgroup *cgroup_get_from_id(u64 id) @@ -6037,7 +6037,7 @@ struct cgroup *cgroup_get_from_id(u64 id) cgrp = NULL; } out: - return cgrp; + return cgrp ?: ERR_PTR(-ENOENT); } EXPORT_SYMBOL_GPL(cgroup_get_from_id); |