diff options
author | Xiu Jianfeng <xiujianfeng@huawei.com> | 2024-08-05 00:43:04 +0000 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2024-08-05 10:32:16 -1000 |
commit | 4980f712023a1c0c26a12f5212ced34587d81663 (patch) | |
tree | c2f690efda762b9c5ac1072e26769cb741d2a5cf /kernel/cgroup/pids.c | |
parent | 563ea1f5f85171b68f9075f5c3c22c4b521f1b5e (diff) | |
download | lwn-4980f712023a1c0c26a12f5212ced34587d81663.tar.gz lwn-4980f712023a1c0c26a12f5212ced34587d81663.zip |
cgroup/pids: Remove unreachable paths of pids_{can,cancel}_fork
According to the implementation of cgroup_css_set_fork(), it will fail
if cset cannot be found and the can_fork/cancel_fork methods will not
be called in this case, which means that the argument 'cset' for these
methods must not be NULL, so remove the unrechable paths in them.
Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com>
Reviewed-by: Waiman Long <longman@redhat.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
Diffstat (limited to 'kernel/cgroup/pids.c')
-rw-r--r-- | kernel/cgroup/pids.c | 14 |
1 files changed, 2 insertions, 12 deletions
diff --git a/kernel/cgroup/pids.c b/kernel/cgroup/pids.c index 34aa63d7c9c6..8f61114c36dd 100644 --- a/kernel/cgroup/pids.c +++ b/kernel/cgroup/pids.c @@ -272,15 +272,10 @@ static void pids_event(struct pids_cgroup *pids_forking, */ static int pids_can_fork(struct task_struct *task, struct css_set *cset) { - struct cgroup_subsys_state *css; struct pids_cgroup *pids, *pids_over_limit; int err; - if (cset) - css = cset->subsys[pids_cgrp_id]; - else - css = task_css_check(current, pids_cgrp_id, true); - pids = css_pids(css); + pids = css_pids(cset->subsys[pids_cgrp_id]); err = pids_try_charge(pids, 1, &pids_over_limit); if (err) pids_event(pids, pids_over_limit); @@ -290,14 +285,9 @@ static int pids_can_fork(struct task_struct *task, struct css_set *cset) static void pids_cancel_fork(struct task_struct *task, struct css_set *cset) { - struct cgroup_subsys_state *css; struct pids_cgroup *pids; - if (cset) - css = cset->subsys[pids_cgrp_id]; - else - css = task_css_check(current, pids_cgrp_id, true); - pids = css_pids(css); + pids = css_pids(cset->subsys[pids_cgrp_id]); pids_uncharge(pids, 1); } |