Commit fb2211a5 authored by David Vernet's avatar David Vernet Committed by Alexei Starovoitov

bpf: Remove now-unnecessary NULL checks for KF_RELEASE kfuncs

Now that we're not invoking kfunc destructors when the kptr in a map was
NULL, we no longer require NULL checks in many of our KF_RELEASE kfuncs.
This patch removes those NULL checks.
Signed-off-by: default avatarDavid Vernet <void@manifault.com>
Link: https://lore.kernel.org/r/20230325213144.486885-3-void@manifault.comSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parent 1431d0b5
...@@ -342,9 +342,6 @@ hid_bpf_release_context(struct hid_bpf_ctx *ctx) ...@@ -342,9 +342,6 @@ hid_bpf_release_context(struct hid_bpf_ctx *ctx)
{ {
struct hid_bpf_ctx_kern *ctx_kern; struct hid_bpf_ctx_kern *ctx_kern;
if (!ctx)
return;
ctx_kern = container_of(ctx, struct hid_bpf_ctx_kern, ctx); ctx_kern = container_of(ctx, struct hid_bpf_ctx_kern, ctx);
kfree(ctx_kern); kfree(ctx_kern);
......
...@@ -102,9 +102,6 @@ static void cpumask_free_cb(struct rcu_head *head) ...@@ -102,9 +102,6 @@ static void cpumask_free_cb(struct rcu_head *head)
*/ */
__bpf_kfunc void bpf_cpumask_release(struct bpf_cpumask *cpumask) __bpf_kfunc void bpf_cpumask_release(struct bpf_cpumask *cpumask)
{ {
if (!cpumask)
return;
if (refcount_dec_and_test(&cpumask->usage)) if (refcount_dec_and_test(&cpumask->usage))
call_rcu(&cpumask->rcu, cpumask_free_cb); call_rcu(&cpumask->rcu, cpumask_free_cb);
} }
......
...@@ -2089,9 +2089,6 @@ __bpf_kfunc struct task_struct *bpf_task_kptr_get(struct task_struct **pp) ...@@ -2089,9 +2089,6 @@ __bpf_kfunc struct task_struct *bpf_task_kptr_get(struct task_struct **pp)
*/ */
__bpf_kfunc void bpf_task_release(struct task_struct *p) __bpf_kfunc void bpf_task_release(struct task_struct *p)
{ {
if (!p)
return;
put_task_struct(p); put_task_struct(p);
} }
...@@ -2148,9 +2145,6 @@ __bpf_kfunc struct cgroup *bpf_cgroup_kptr_get(struct cgroup **cgrpp) ...@@ -2148,9 +2145,6 @@ __bpf_kfunc struct cgroup *bpf_cgroup_kptr_get(struct cgroup **cgrpp)
*/ */
__bpf_kfunc void bpf_cgroup_release(struct cgroup *cgrp) __bpf_kfunc void bpf_cgroup_release(struct cgroup *cgrp)
{ {
if (!cgrp)
return;
cgroup_put(cgrp); cgroup_put(cgrp);
} }
......
...@@ -615,9 +615,6 @@ bpf_kfunc_call_memb_acquire(void) ...@@ -615,9 +615,6 @@ bpf_kfunc_call_memb_acquire(void)
__bpf_kfunc void bpf_kfunc_call_test_release(struct prog_test_ref_kfunc *p) __bpf_kfunc void bpf_kfunc_call_test_release(struct prog_test_ref_kfunc *p)
{ {
if (!p)
return;
refcount_dec(&p->cnt); refcount_dec(&p->cnt);
} }
......
...@@ -401,8 +401,6 @@ __bpf_kfunc struct nf_conn *bpf_ct_insert_entry(struct nf_conn___init *nfct_i) ...@@ -401,8 +401,6 @@ __bpf_kfunc struct nf_conn *bpf_ct_insert_entry(struct nf_conn___init *nfct_i)
*/ */
__bpf_kfunc void bpf_ct_release(struct nf_conn *nfct) __bpf_kfunc void bpf_ct_release(struct nf_conn *nfct)
{ {
if (!nfct)
return;
nf_ct_put(nfct); nf_ct_put(nfct);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment