提交 798d2258 编写于 作者: M Mauricio Vásquez 提交者: Zheng Zengkai

libbpf: Fix memory leak in btf__dedup()

mainline inclusion
from mainline-5.16-rc1
commit 1000298c
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I5EUVD
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=1000298c76830bc291358e98e8fa5baa3baa9b3a

-------------------------------------------------

Free btf_dedup if btf_ensure_modifiable() returns error.

Fixes: 919d2b1d ("libbpf: Allow modification of BTF and add btf__add_str API")
Signed-off-by: NMauricio Vásquez <mauricio@kinvolk.io>
Signed-off-by: NAndrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20211022202035.48868-1-mauricio@kinvolk.io
(cherry picked from commit 1000298c)
Signed-off-by: NWang Yufen <wangyufen@huawei.com>
上级 b85cd2ea
...@@ -2997,8 +2997,10 @@ int btf__dedup(struct btf *btf, struct btf_ext *btf_ext, ...@@ -2997,8 +2997,10 @@ int btf__dedup(struct btf *btf, struct btf_ext *btf_ext,
return libbpf_err(-EINVAL); return libbpf_err(-EINVAL);
} }
if (btf_ensure_modifiable(btf)) if (btf_ensure_modifiable(btf)) {
return libbpf_err(-ENOMEM); err = -ENOMEM;
goto done;
}
err = btf_dedup_prep(d); err = btf_dedup_prep(d);
if (err) { if (err) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册