From: Carmine Scarpitta Date: Tue, 23 Aug 2022 22:25:17 +0000 (+0200) Subject: sharpd: Fix memory leak in release-locator-chunk X-Git-Tag: base_8.4~86^2~2 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=a0c47583a43138f32cf4c1a3691c289d46ba2933;p=matthieu%2Ffrr.git sharpd: Fix memory leak in release-locator-chunk Running the `zebra_seg6local_route` topotest with `--valgrind-memleaks` gives several memory leak errors. This is due to the way SRv6 chunks are released: when the user executes the CLI command `sharp srv6-manager release-locator-chunk` to release the chunks of an SRv6 locator, all the chunks are removed from the list `loc->chunks`. Also, the locator is removed from the SRv6 locators list `sg.srv6_locators`, but the memory allocated for the locator is not freed. This patch adds a call to `XFREE()` to properly free the allocated memory when all the chunks of an SRv6 locator are removed and the locator is removed as well. Signed-off-by: Carmine Scarpitta --- diff --git a/sharpd/sharp_vty.c b/sharpd/sharp_vty.c index 2281b3ce26..b3ac8949e6 100644 --- a/sharpd/sharp_vty.c +++ b/sharpd/sharp_vty.c @@ -1096,6 +1096,7 @@ DEFPY (sharp_srv6_manager_release_locator_chunk, list_delete_all_node(loc->chunks); list_delete(&loc->chunks); listnode_delete(sg.srv6_locators, loc); + XFREE(MTYPE_SRV6_LOCATOR, loc); break; } }