Skip to content

Commit

Permalink
libbpf: Fix func leak in attach_kprobe
Browse files Browse the repository at this point in the history
Add missing free() for func pointer in attach_kprobe function.

Fixes: a2488b5 ("libbpf: Allow specification of "kprobe/function+offset"")
Reported-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Reviewed-by: Alan Maguire <alan.maguire@oracle.com>
Tested-by: Alan Maguire <alan.maguire@oracle.com>
Link: https://lore.kernel.org/bpf/20210721215810.889975-2-jolsa@kernel.org
  • Loading branch information
Jiri Olsa authored and Andrii Nakryiko committed Jul 23, 2021
1 parent 9907442 commit 1f71a46
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions tools/lib/bpf/libbpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -10431,6 +10431,7 @@ static struct bpf_link *attach_kprobe(const struct bpf_sec_def *sec,
return libbpf_err_ptr(err);
}
if (opts.retprobe && offset != 0) {
free(func);
err = -EINVAL;
pr_warn("kretprobes do not support offset specification\n");
return libbpf_err_ptr(err);
Expand Down

0 comments on commit 1f71a46

Please sign in to comment.