Skip to content

Commit b408473

Browse files
Martin KaFai Lauanakryiko
authored andcommitted
bpf: Fix a crash when btf_parse_base() returns an error pointer
The pointer returned by btf_parse_base could be an error pointer. IS_ERR() check is needed before calling btf_free(base_btf). Fixes: 8646db2 ("libbpf,bpf: Share BTF relocate-related code with kernel") Signed-off-by: Martin KaFai Lau <[email protected]> Signed-off-by: Andrii Nakryiko <[email protected]> Reviewed-by: Alan Maguire <[email protected]> Acked-by: Eduard Zingerman <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent 872cf28 commit b408473

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

kernel/bpf/btf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6283,7 +6283,7 @@ static struct btf *btf_parse_module(const char *module_name, const void *data,
62836283

62846284
errout:
62856285
btf_verifier_env_free(env);
6286-
if (base_btf != vmlinux_btf)
6286+
if (!IS_ERR(base_btf) && base_btf != vmlinux_btf)
62876287
btf_free(base_btf);
62886288
if (btf) {
62896289
kvfree(btf->data);

0 commit comments

Comments
 (0)