btf_loader: Plug leak when bailing out due to unknown tag
Fixes this coverity report:
Error: RESOURCE_LEAK (CWE-772): [#def2]
dwarves-1.13/btf_loader.c:342: alloc_fn: Storage is returned from allocation function "zalloc".
dwarves-1.13/btf_loader.c:342: var_assign: Assigning: "tag" = storage returned from "zalloc(40UL)".
dwarves-1.13/btf_loader.c:354: leaked_storage: Variable "tag" going out of scope leaks the storage it points to.
# 352| default:
# 353| printf("%s: FOO %d\n\n", __func__, type);
# 354|-> return 0;
# 355| }
# 356|
Reported-by: William Cohen <wcohen@redhat.com>
Fixes: 472256d3c5
("btf_loader: Introduce a loader for the BTF format")
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
511a791294
commit
de5e72bc15
|
@ -350,7 +350,8 @@ static int create_new_tag(struct btf_elf *btfe, int type, struct btf_type *tp, u
|
|||
case BTF_KIND_RESTRICT: tag->tag = DW_TAG_restrict_type; break;
|
||||
case BTF_KIND_VOLATILE: tag->tag = DW_TAG_volatile_type; break;
|
||||
default:
|
||||
printf("%s: FOO %d\n\n", __func__, type);
|
||||
free(tag);
|
||||
printf("%s: Unknown type %d\n\n", __func__, type);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue