summaryrefslogtreecommitdiff
path: root/lib/srv6.c
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@nvidia.com>2022-12-14 15:53:06 -0500
committerDonald Sharp <sharpd@nvidia.com>2022-12-15 11:15:33 -0500
commit1fec35c3c7e212e41224035e1c04e2c211634d72 (patch)
treed4a2444e26d4eff8861db84ff6c58e04ac4cf94d /lib/srv6.c
parent6354d63593d717b4b9a0920cd3a7e6dec10b6e50 (diff)
lib: Fix free function
The list delete function on creation was set to srv6_locator_chunk_free Which takes a double pointer and dereferences it to free the data. When list_delete is called it calls the delete function like this: if (*list->del) (*list->del)(node->data); The data is not passed in by reference and as such we do not have a double pointer. Fortunately this list_delete is only really called on shutdown when the locator was deleted and we do not have a fun situation where we were suddenly freeing 'something'. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
Diffstat (limited to 'lib/srv6.c')
-rw-r--r--lib/srv6.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/srv6.c b/lib/srv6.c
index 5cd82080f5..f4077a86d2 100644
--- a/lib/srv6.c
+++ b/lib/srv6.c
@@ -121,6 +121,13 @@ const char *seg6local_context2str(char *str, size_t size,
}
}
+static void srv6_locator_chunk_list_free(void *data)
+{
+ struct srv6_locator_chunk *chunk = data;
+
+ srv6_locator_chunk_free(&chunk);
+}
+
struct srv6_locator *srv6_locator_alloc(const char *name)
{
struct srv6_locator *locator = NULL;
@@ -128,7 +135,7 @@ struct srv6_locator *srv6_locator_alloc(const char *name)
locator = XCALLOC(MTYPE_SRV6_LOCATOR, sizeof(struct srv6_locator));
strlcpy(locator->name, name, sizeof(locator->name));
locator->chunks = list_new();
- locator->chunks->del = (void (*)(void *))srv6_locator_chunk_free;
+ locator->chunks->del = srv6_locator_chunk_list_free;
QOBJ_REG(locator, srv6_locator);
return locator;