test-aa: Fix memory leak reported by valgrind.
authorWilliam Tu <u9012063@gmail.com>
Thu, 7 Jan 2016 02:35:23 +0000 (18:35 -0800)
committerBen Pfaff <blp@ovn.org>
Mon, 11 Jan 2016 17:02:03 +0000 (09:02 -0800)
commit9547cc66f5ee35209da988717556dcaf1fb28a23
tree6c577a7747b6d68214b76898b1034848e13cd38c
parentcf2bc30c6ad5f3dfe9c5f55550fffb20efde6b06
test-aa: Fix memory leak reported by valgrind.

test case 1698: auto-attach - packet tests
Report several leaks at lldp_create_dummy(), the patch fixes the
following 3 leaks:
    {lldp_send (lldp.c:334), lldp_decode (lldp.c:374),
     lldp_create_dummy (ovs-lldp.c:890)}
    test_aa_send (test-aa.c:252)
    test_aa_main (test-aa.c:281)
Comments:
    1. Create a new function "lldp_destroy_dummy()" because
       many structures and its elements, ex: lldp_hardware and lldp_chassis,
       are from stack not heap (see test_aa_send). As a result, calling
       lldpd_cleanup() is incorrect.
    2. Remove lchassis->c_id = xmalloc(ETH_ADDR_LEN);
       because it is overwritten at test_aa_send()
    3. remove memcpy(&hw->h_lport.p_element.system_id.system_mac,
           lchassis->c_id, lchassis->c_id_len);
       because the source buf is empty

Signed-off-by: William Tu <u9012063@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
lib/ovs-lldp.c
lib/ovs-lldp.h
tests/test-aa.c