Skip to content

Commit

Permalink
selftests/bpf: Free inner strings index in btf selftest
Browse files Browse the repository at this point in the history
Inner array of allocated strings wasn't freed on success. Now it's
always freed.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Reviewed-by: Hengqi Chen <hengqi.chen@gmail.com>
Link: https://lore.kernel.org/bpf/20211107165521.9240-6-andrii@kernel.org
  • Loading branch information
Andrii Nakryiko authored and Alexei Starovoitov committed Nov 7, 2021
1 parent b8b26e5 commit 5309b51
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions tools/testing/selftests/bpf/prog_tests/btf.c
Original file line number Diff line number Diff line change
Expand Up @@ -4046,11 +4046,9 @@ static void *btf_raw_create(const struct btf_header *hdr,
next_str_idx < strs_cnt ? strs_idx[next_str_idx] : NULL;

done:
free(strs_idx);
if (err) {
if (raw_btf)
free(raw_btf);
if (strs_idx)
free(strs_idx);
free(raw_btf);
return NULL;
}
return raw_btf;
Expand Down

0 comments on commit 5309b51

Please sign in to comment.