Skip to contentSkip to conversation

bpf: Fix memory leak in bpf_core_apply

PATCH Applied Jiri Olsa 3 participants 3 messages Oct 7, 2024 – Oct 8, 2024 BPF

lore
Share & tools
lore

Jiri Olsa

author reviewer
#0 lore raw

PATCH 1/1 bpf: Fix memory leak in bpf_core_apply

We need to free specs properly.

Cc Eduard Zingerman <[email protected]>
Fixes 3d2786d65aaa ("bpf: correctly handle malformed BPF_CORE_TYPE_ID_LOCAL relos")
---
 kernel/bpf/btf.c | 1 +
 1 file changed, 1 insertion(+)
kernel/bpf/btf.c +1 -0
index 75e4fe83c509..a05da5f43547 100644
@@ -8961,6 +8961,7 @@ int bpf_core_apply(struct bpf_core_ctx *ctx, const struct bpf_core_relo *relo,
 	if (!type) {
 		bpf_log(ctx->log, "relo #%u: bad type id %u\n",
 			relo_idx, relo->type_id);
+		kfree(specs);
 		return -EINVAL;
 	}
 
Signature · 1 line
2.46.2
#2 lore raw
In reply to Jiri Olsa
This patch was applied to bpf/bpf.git (master) by Andrii Nakryiko <[email protected]>:

Hello:

This patch was applied to bpf/bpf.git (master)
by Andrii Nakryiko <[email protected]>:

Quoted 8 lines · On Mon, 7 Oct 2024 18:09:58 +0200 you wrote:

We need to free specs properly.

Cc Eduard Zingerman <[email protected]>
Fixes 3d2786d65aaa ("bpf: correctly handle malformed BPF_CORE_TYPE_ID_LOCAL relos")
---
 kernel/bpf/btf.c | 1 +
 1 file changed, 1 insertion(+)

Here is the summary with links:
- [bpf] bpf: Fix memory leak in bpf_core_apply

    https://git.kernel.org/bpf/bpf/c/45126b155e3b

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html