summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@kernel.org>2022-08-02 15:56:51 +0200
committerAndrii Nakryiko <andrii@kernel.org>2022-08-05 09:43:58 -0700
commit62d468e5e10012e8b67d066ba7bac0a8afdc3cee (patch)
treee59c70f1f60ed7ea69378edc72483190cb7d1706 /kernel
parente2dcac2f58f5a95ab092d1da237ffdc0da1832cf (diff)
bpf: Cleanup ftrace hash in bpf_trampoline_put
We need to release possible hash from trampoline fops object before removing it, otherwise we leak it. Fixes: 00963a2e75a8 ("bpf: Support bpf_trampoline on functions with IPMODIFY (e.g. livepatch)") Signed-off-by: Jiri Olsa <jolsa@kernel.org> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Acked-by: Song Liu <song@kernel.org> Link: https://lore.kernel.org/bpf/20220802135651.1794015-1-jolsa@kernel.org
Diffstat (limited to 'kernel')
-rw-r--r--kernel/bpf/trampoline.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/kernel/bpf/trampoline.c b/kernel/bpf/trampoline.c
index 0f532e6a717f..ff87e38af8a7 100644
--- a/kernel/bpf/trampoline.c
+++ b/kernel/bpf/trampoline.c
@@ -841,7 +841,10 @@ void bpf_trampoline_put(struct bpf_trampoline *tr)
* multiple rcu callbacks.
*/
hlist_del(&tr->hlist);
- kfree(tr->fops);
+ if (tr->fops) {
+ ftrace_free_filter(tr->fops);
+ kfree(tr->fops);
+ }
kfree(tr);
out:
mutex_unlock(&trampoline_mutex);