Skip to content

Commit

Permalink
ovn-northd: Fix memory leak in case of distributed NAT.
Browse files Browse the repository at this point in the history
In function get_nat_addresses(), memory reserved for c_addresses is not
freed in case of distributed NAT (i.e., central_ip_address == false):

==22493== 36 bytes in 2 blocks are definitely lost in loss record 176
of 444
==22493==    at 0x4C29DAD: malloc (vg_replace_malloc.c:308)
==22493==    by 0x4C2C100: realloc (vg_replace_malloc.c:836)
==22493==    by 0x4E3E9D: xrealloc (util.c:149)
==22493==    by 0x47EEBB: ds_reserve (dynamic-string.c:63)
==22493==    by 0x47F32E: ds_put_format_valist (dynamic-string.c:161)
==22493==    by 0x47F258: ds_put_format (dynamic-string.c:142)
==22493==    by 0x40D74E: get_nat_addresses (ovn-northd.c:2337)
==22493==    by 0x40F75B: ovn_port_update_sbrec (ovn-northd.c:2981)
==22493==    by 0x4112E8: build_ports (ovn-northd.c:3505)
==22493==    by 0x42922C: ovnnb_db_run (ovn-northd.c:11138)
==22493==    by 0x42A49D: ovn_db_run (ovn-northd.c:11692)
==22493==    by 0x42B484: main (ovn-northd.c:12055)

To fix this we always call ds_destroy(&c_addresses).

Fixes: 7b1f4da ("ovn: Gratuitous ARP for distributed NAT rules")
Signed-off-by: Dumitru Ceara <dceara@redhat.com>
Acked-by: Ilya Maximets <i.maximets@ovn.org>
Signed-off-by: Numan Siddique <numans@ovn.org>
  • Loading branch information
dceara authored and numansiddique committed May 14, 2020
1 parent 148dfa4 commit 53f8e9e
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions northd/ovn-northd.c
Original file line number Diff line number Diff line change
Expand Up @@ -2424,6 +2424,7 @@ get_nat_addresses(const struct ovn_port *op, size_t *n)
}

*n = n_nats;
ds_destroy(&c_addresses);

return addresses;
}
Expand Down

0 comments on commit 53f8e9e

Please sign in to comment.