diff options
author | Mauricio Vásquez <mauricio@kinvolk.io> | 2021-10-22 23:20:35 +0300 |
---|---|---|
committer | Andrii Nakryiko <andrii@kernel.org> | 2021-10-23 02:00:53 +0300 |
commit | 1000298c76830bc291358e98e8fa5baa3baa9b3a (patch) | |
tree | d4180ef03c40382c4d9880dd1d02b6273f288caf /tools/lib | |
parent | 57385ae31ff0ffa6e9c9ae39206740efdc7f5972 (diff) | |
download | linux-1000298c76830bc291358e98e8fa5baa3baa9b3a.tar.xz |
libbpf: Fix memory leak in btf__dedup()
Free btf_dedup if btf_ensure_modifiable() returns error.
Fixes: 919d2b1dbb07 ("libbpf: Allow modification of BTF and add btf__add_str API")
Signed-off-by: Mauricio Vásquez <mauricio@kinvolk.io>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20211022202035.48868-1-mauricio@kinvolk.io
Diffstat (limited to 'tools/lib')
-rw-r--r-- | tools/lib/bpf/btf.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/btf.c index 3a01c4b7f36a..85705c10f7b2 100644 --- a/tools/lib/bpf/btf.c +++ b/tools/lib/bpf/btf.c @@ -2991,8 +2991,10 @@ int btf__dedup(struct btf *btf, struct btf_ext *btf_ext, return libbpf_err(-EINVAL); } - if (btf_ensure_modifiable(btf)) - return libbpf_err(-ENOMEM); + if (btf_ensure_modifiable(btf)) { + err = -ENOMEM; + goto done; + } err = btf_dedup_prep(d); if (err) { |