summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Jones <pjones@redhat.com>2021-03-27 18:04:02 -0400
committerPeter Jones <pjones@redhat.com>2021-03-28 13:20:04 -0400
commitd12ca07e095ebce53cdef205f872185f3cd42b14 (patch)
tree9c7e14ec571bcf137fe929d750afb8fac74cf5f8
parent977c6949428b922470715583ca76127a44f6e8bc (diff)
downloadefi-boot-shim-d12ca07e095ebce53cdef205f872185f3cd42b14.tar.gz
efi-boot-shim-d12ca07e095ebce53cdef205f872185f3cd42b14.zip
test_parse_sbat_section_too_many_elem(): free section entries
valgrind noticed test_parse_sbat_section_too_many_elem() this wasn't doing cleanup properly. This changes it to clean up without respect to the results. Before: ==2432919== ==2432919== HEAP SUMMARY: ==2432919== in use at exit: 365 bytes in 4 blocks ==2432919== total heap usage: 17 allocs, 13 frees, 2,310 bytes allocated ==2432919== ==2432919== 15 bytes in 1 blocks are definitely lost in loss record 1 of 4 ==2432919== at 0x4845464: calloc (vg_replace_malloc.c:1117) ==2432919== by 0x401D21: UnknownInlinedFun (test-sbat.c:936) ==2432919== by 0x401D21: main (test-sbat.c:1042) ==2432919== ==2432919== 56 bytes in 1 blocks are definitely lost in loss record 2 of 4 ==2432919== at 0x4845464: calloc (vg_replace_malloc.c:1117) ==2432919== by 0x402B1B: parse_sbat_var_data (sbat.c:234) ==2432919== by 0x40189C: UnknownInlinedFun (test-sbat.c:444) ==2432919== by 0x40189C: main (test-sbat.c:1028) ==2432919== ==2432919== 110 bytes in 1 blocks are definitely lost in loss record 3 of 4 ==2432919== at 0x4845464: calloc (vg_replace_malloc.c:1117) ==2432919== by 0x402B1B: parse_sbat_var_data (sbat.c:234) ==2432919== by 0x401D67: UnknownInlinedFun (test-sbat.c:942) ==2432919== by 0x401D67: main (test-sbat.c:1042) ==2432919== ==2432919== 184 bytes in 1 blocks are definitely lost in loss record 4 of 4 ==2432919== at 0x4845464: calloc (vg_replace_malloc.c:1117) ==2432919== by 0x402CD3: parse_sbat_section (sbat.c:56) ==2432919== by 0x4015A8: UnknownInlinedFun (test-sbat.c:323) ==2432919== by 0x4015A8: main (test-sbat.c:1019) ==2432919== ==2432919== LEAK SUMMARY: ==2432919== definitely lost: 365 bytes in 4 blocks ==2432919== indirectly lost: 0 bytes in 0 blocks ==2432919== possibly lost: 0 bytes in 0 blocks ==2432919== still reachable: 0 bytes in 0 blocks ==2432919== suppressed: 0 bytes in 0 blocks ==2432919== ==2432919== For lists of detected and suppressed errors, rerun with: -s ==2432919== ERROR SUMMARY: 4 errors from 4 contexts (suppressed: 0 from 0) After: ==2525955== ==2525955== HEAP SUMMARY: ==2525955== in use at exit: 181 bytes in 3 blocks ==2525955== total heap usage: 17 allocs, 14 frees, 2,310 bytes allocated ==2525955== ==2525955== 15 bytes in 1 blocks are definitely lost in loss record 1 of 3 ==2525955== at 0x4845464: calloc (vg_replace_malloc.c:1117) ==2525955== by 0x401D21: UnknownInlinedFun (test-sbat.c:937) ==2525955== by 0x401D21: main (test-sbat.c:1043) ==2525955== ==2525955== 56 bytes in 1 blocks are definitely lost in loss record 2 of 3 ==2525955== at 0x4845464: calloc (vg_replace_malloc.c:1117) ==2525955== by 0x402ACB: parse_sbat_var_data (sbat.c:234) ==2525955== by 0x40189D: UnknownInlinedFun (test-sbat.c:445) ==2525955== by 0x40189D: main (test-sbat.c:1029) ==2525955== ==2525955== 110 bytes in 1 blocks are definitely lost in loss record 3 of 3 ==2525955== at 0x4845464: calloc (vg_replace_malloc.c:1117) ==2525955== by 0x402ACB: parse_sbat_var_data (sbat.c:234) ==2525955== by 0x401D67: UnknownInlinedFun (test-sbat.c:943) ==2525955== by 0x401D67: main (test-sbat.c:1043) ==2525955== ==2525955== LEAK SUMMARY: ==2525955== definitely lost: 181 bytes in 3 blocks ==2525955== indirectly lost: 0 bytes in 0 blocks ==2525955== possibly lost: 0 bytes in 0 blocks ==2525955== still reachable: 0 bytes in 0 blocks ==2525955== suppressed: 0 bytes in 0 blocks ==2525955== ==2525955== For lists of detected and suppressed errors, rerun with: -s ==2525955== ERROR SUMMARY: 3 errors from 3 contexts (suppressed: 0 from 0) Signed-off-by: Peter Jones <pjones@redhat.com>
-rw-r--r--test-sbat.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/test-sbat.c b/test-sbat.c
index 8b94ecf0..8f361da6 100644
--- a/test-sbat.c
+++ b/test-sbat.c
@@ -319,6 +319,7 @@ test_parse_sbat_section_too_many_elem(void)
struct sbat_section_entry *test_entries[] = {
&test_section_entry1, &test_section_entry2,
};
+ int rc = -1;
status = parse_sbat_section(section_base, section_size, &n, &entries);
assert_equal_return(status, EFI_SUCCESS, -1, "got %#hhx expected %#hhx\n");
@@ -341,10 +342,10 @@ test_parse_sbat_section_too_many_elem(void)
#undef mkassert
}
assert_equal_goto(n, 2, fail, "got %zu expected %d\n");
- return 0;
+ rc = 0;
fail:
cleanup_sbat_section_entries(n, entries);
- return -1;
+ return rc;
}
/*