Skip to content

Commit

Permalink
test_astlpc: Clean up after test case
Browse files Browse the repository at this point in the history
Free all allocated memory to avoid false-positive leak reports.

Resolves:

    ==11807==ERROR: LeakSanitizer: detected memory leaks

    Indirect leak of 552 byte(s) in 1 object(s) allocated from:
        #0 0x7f74718fbae8 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0x10dae8)
        #1 0x7f74717bacf0 in __mctp_alloc /home/andrew/src/openbmc/libmctp/alloc.c:28
        #2 0x7f74717b5edc in mctp_init /home/andrew/src/openbmc/libmctp/core.c:234
        #3 0x56157917c7ee in main tests/test_astlpc.c:160
        #4 0x7f7470c661e2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x271e2)

    Indirect leak of 384 byte(s) in 1 object(s) allocated from:
        #0 0x7f74718fbae8 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0x10dae8)
        #1 0x7f74717bacf0 in __mctp_alloc /home/andrew/src/openbmc/libmctp/alloc.c:28
        #2 0x7f74717c2cd0 in __mctp_astlpc_init /home/andrew/src/openbmc/libmctp/astlpc.c:364
        #3 0x7f74717c31f0 in mctp_astlpc_init_ops /home/andrew/src/openbmc/libmctp/astlpc.c:388
        #4 0x56157917c88f in main tests/test_astlpc.c:165
        #5 0x7f7470c661e2 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 0x7f74718fbae8 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0x10dae8)
        #1 0x7f74717bacf0 in __mctp_alloc /home/andrew/src/openbmc/libmctp/alloc.c:28
        #2 0x7f74717b655f in mctp_register_bus /home/andrew/src/openbmc/libmctp/core.c:277
        #3 0x56157917c903 in main tests/test_astlpc.c:167
        #4 0x7f7470c661e2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x271e2)

    Indirect leak of 32 byte(s) in 1 object(s) allocated from:
        #0 0x7f74718fbae8 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0x10dae8)
        #1 0x7f74717bacf0 in __mctp_alloc /home/andrew/src/openbmc/libmctp/alloc.c:28
        #2 0x7f74717c34b2 in mctp_astlpc_init_ops /home/andrew/src/openbmc/libmctp/astlpc.c:400
        #3 0x56157917c88f in main tests/test_astlpc.c:165
        #4 0x7f7470c661e2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x271e2)

Signed-off-by: Andrew Jeffery <[email protected]>
Change-Id: I3f67e48b22948e18aea91d6fa28135e528268bc1
  • Loading branch information
amboar committed Mar 10, 2020
1 parent 4663f67 commit 11b7e92
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tests/test_astlpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,5 +211,9 @@ int main(void)
/* Verify it's the packet we expect */
assert(!memcmp(mmio.lpc + RX_BUFFER_DATA, &msg[MCTP_BTU], MCTP_BTU));

mctp_astlpc_destroy(astlpc);
mctp_destroy(mctp);
free(mmio.lpc);

return 0;
}

0 comments on commit 11b7e92

Please sign in to comment.