* [PATCH bpf-next] libbpf: fix memory leak in attach_tp for target-less tracepoint program
@ 2022-05-16 18:45 Andrii Nakryiko
2022-05-16 19:03 ` David Vernet
2022-05-16 20:50 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Andrii Nakryiko @ 2022-05-16 18:45 UTC (permalink / raw)
To: bpf, ast, daniel; +Cc: andrii, kernel-team
Fix sec_name memory leak if user defines target-less SEC("tp").
Fixes: 9af8efc45eb1 ("libbpf: Allow "incomplete" basic tracing SEC() definitions")
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
---
tools/lib/bpf/libbpf.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index 9aae886cbabf..ef7f302e542f 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -11592,16 +11592,16 @@ static int attach_tp(const struct bpf_program *prog, long cookie, struct bpf_lin
{
char *sec_name, *tp_cat, *tp_name;
- sec_name = strdup(prog->sec_name);
- if (!sec_name)
- return -ENOMEM;
-
*link = NULL;
/* no auto-attach for SEC("tp") or SEC("tracepoint") */
if (strcmp(prog->sec_name, "tp") == 0 || strcmp(prog->sec_name, "tracepoint") == 0)
return 0;
+ sec_name = strdup(prog->sec_name);
+ if (!sec_name)
+ return -ENOMEM;
+
/* extract "tp/<category>/<name>" or "tracepoint/<category>/<name>" */
if (str_has_pfx(prog->sec_name, "tp/"))
tp_cat = sec_name + sizeof("tp/") - 1;
--
2.30.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH bpf-next] libbpf: fix memory leak in attach_tp for target-less tracepoint program
2022-05-16 18:45 [PATCH bpf-next] libbpf: fix memory leak in attach_tp for target-less tracepoint program Andrii Nakryiko
@ 2022-05-16 19:03 ` David Vernet
2022-05-16 20:50 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: David Vernet @ 2022-05-16 19:03 UTC (permalink / raw)
To: Andrii Nakryiko; +Cc: bpf, ast, daniel, kernel-team
On Mon, May 16, 2022 at 11:45:47AM -0700, Andrii Nakryiko wrote:
> Fix sec_name memory leak if user defines target-less SEC("tp").
>
> Fixes: 9af8efc45eb1 ("libbpf: Allow "incomplete" basic tracing SEC() definitions")
> Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
> ---
LGTM
Acked-by: David Vernet <void@manifault.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH bpf-next] libbpf: fix memory leak in attach_tp for target-less tracepoint program
2022-05-16 18:45 [PATCH bpf-next] libbpf: fix memory leak in attach_tp for target-less tracepoint program Andrii Nakryiko
2022-05-16 19:03 ` David Vernet
@ 2022-05-16 20:50 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-05-16 20:50 UTC (permalink / raw)
To: Andrii Nakryiko; +Cc: bpf, ast, daniel, kernel-team
Hello:
This patch was applied to bpf/bpf-next.git (master)
by Alexei Starovoitov <ast@kernel.org>:
On Mon, 16 May 2022 11:45:47 -0700 you wrote:
> Fix sec_name memory leak if user defines target-less SEC("tp").
>
> Fixes: 9af8efc45eb1 ("libbpf: Allow "incomplete" basic tracing SEC() definitions")
> Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
> ---
> tools/lib/bpf/libbpf.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
Here is the summary with links:
- [bpf-next] libbpf: fix memory leak in attach_tp for target-less tracepoint program
https://git.kernel.org/bpf/bpf-next/c/ac6a65868a5a
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-05-16 21:09 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-16 18:45 [PATCH bpf-next] libbpf: fix memory leak in attach_tp for target-less tracepoint program Andrii Nakryiko
2022-05-16 19:03 ` David Vernet
2022-05-16 20:50 ` patchwork-bot+netdevbpf
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.