]> git.puffer.fish Git - matthieu/frr.git/commitdiff
sharpd: Fix memory leak in release-locator-chunk
authorCarmine Scarpitta <carmine.scarpitta@uniroma2.it>
Tue, 23 Aug 2022 22:25:17 +0000 (00:25 +0200)
committerCarmine Scarpitta <carmine.scarpitta@uniroma2.it>
Wed, 24 Aug 2022 12:22:04 +0000 (14:22 +0200)
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 <carmine.scarpitta@uniroma2.it>
sharpd/sharp_vty.c

index 2281b3ce2607dfeafb664e1542da6b15822c1e8f..b3ac8949e615804b54197a9ae16dc014f4a229e3 100644 (file)
@@ -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;
                }
        }