Skip to content

Commit 1000298

Browse files
mauriciovasquezbernalanakryiko
authored andcommitted
libbpf: Fix memory leak in btf__dedup()
Free btf_dedup if btf_ensure_modifiable() returns error. Fixes: 919d2b1 ("libbpf: Allow modification of BTF and add btf__add_str API") Signed-off-by: Mauricio Vásquez <[email protected]> Signed-off-by: Andrii Nakryiko <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent 57385ae commit 1000298

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

tools/lib/bpf/btf.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2991,8 +2991,10 @@ int btf__dedup(struct btf *btf, struct btf_ext *btf_ext,
29912991
return libbpf_err(-EINVAL);
29922992
}
29932993

2994-
if (btf_ensure_modifiable(btf))
2995-
return libbpf_err(-ENOMEM);
2994+
if (btf_ensure_modifiable(btf)) {
2995+
err = -ENOMEM;
2996+
goto done;
2997+
}
29962998

29972999
err = btf_dedup_prep(d);
29983000
if (err) {

0 commit comments

Comments
 (0)