From 7c73801e82eb3b30d7c1cd2a131158595f96087d Mon Sep 17 00:00:00 2001 From: Andrew Jeffery Date: Tue, 10 Mar 2020 23:28:13 +1030 Subject: [PATCH] test_eid: Clean up after test case Free all allocated memory to avoid false-positive leak reports. Resolves: ==10460==ERROR: LeakSanitizer: detected memory leaks Indirect leak of 552 byte(s) in 1 object(s) allocated from: #0 0x7f3e1a574ae8 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0x10dae8) #1 0x7f3e1a433cf0 in __mctp_alloc /home/andrew/src/openbmc/libmctp/alloc.c:28 #2 0x7f3e1a42eedc in mctp_init /home/andrew/src/openbmc/libmctp/core.c:234 #3 0x55f705f81268 in mctp_test_stack_init tests/test-utils.c:63 #4 0x55f705f7edff in main tests/test_eid.c:51 #5 0x7f3e198df1e2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x271e2) Indirect leak of 56 byte(s) in 1 object(s) allocated from: #0 0x7f3e1a574ae8 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0x10dae8) #1 0x7f3e1a433cf0 in __mctp_alloc /home/andrew/src/openbmc/libmctp/alloc.c:28 #2 0x55f705f80c99 in mctp_binding_test_init tests/test-utils.c:27 #3 0x55f705f812e1 in mctp_test_stack_init tests/test-utils.c:66 #4 0x55f705f7edff in main tests/test_eid.c:51 #5 0x7f3e198df1e2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x271e2) Indirect leak of 40 byte(s) in 1 object(s) allocated from: #0 0x7f3e1a574ae8 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0x10dae8) #1 0x7f3e1a433cf0 in __mctp_alloc /home/andrew/src/openbmc/libmctp/alloc.c:28 #2 0x7f3e1a42f55f in mctp_register_bus /home/andrew/src/openbmc/libmctp/core.c:277 #3 0x55f705f8121b in mctp_binding_test_register_bus tests/test-utils.c:56 #4 0x55f705f81405 in mctp_test_stack_init tests/test-utils.c:69 #5 0x55f705f7edff in main tests/test_eid.c:51 #6 0x7f3e198df1e2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x271e2) Signed-off-by: Andrew Jeffery Change-Id: I34eae31219d4a31e8388d180be746ae8b7ec5c04 --- tests/test_eid.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/test_eid.c b/tests/test_eid.c index c4ab9da2..51f989cb 100644 --- a/tests/test_eid.c +++ b/tests/test_eid.c @@ -71,5 +71,8 @@ int main(void) assert(ctx->rx_count == 0); + mctp_binding_test_destroy(ctx->binding); + mctp_destroy(ctx->mctp); + return EXIT_SUCCESS; }