mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-07-24 14:56:05 +00:00
ospfd: Cleanup some memory leaks on shutdown in ospf_apiserver.c
Clean up some memory leaks found in ospf_apiserver.c Also
a crash in the original implementation.
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
(cherry picked from commit 7773d0071a
)
This commit is contained in:
parent
e4aa127939
commit
89992e547c
@ -181,9 +181,14 @@ void ospf_apiserver_term(void)
|
||||
* Free all client instances. ospf_apiserver_free removes the node
|
||||
* from the list, so we examine the head of the list anew each time.
|
||||
*/
|
||||
while (apiserver_list
|
||||
&& (apiserv = listgetdata(listhead(apiserver_list))) != NULL)
|
||||
if (!apiserver_list)
|
||||
return;
|
||||
|
||||
while (listcount(apiserver_list)) {
|
||||
apiserv = listgetdata(listhead(apiserver_list));
|
||||
|
||||
ospf_apiserver_free(apiserv);
|
||||
}
|
||||
|
||||
/* Free client list itself */
|
||||
if (apiserver_list)
|
||||
@ -338,6 +343,7 @@ void ospf_apiserver_free(struct ospf_apiserver *apiserv)
|
||||
ospf_apiserver_unregister_opaque_type(
|
||||
apiserv, regtype->lsa_type, regtype->opaque_type);
|
||||
}
|
||||
list_delete(&apiserv->opaque_types);
|
||||
|
||||
/* Close connections to OSPFd. */
|
||||
if (apiserv->fd_sync > 0) {
|
||||
@ -359,6 +365,8 @@ void ospf_apiserver_free(struct ospf_apiserver *apiserv)
|
||||
/* Remove from the list of active clients. */
|
||||
listnode_delete(apiserver_list, apiserv);
|
||||
|
||||
XFREE(MTYPE_APISERVER_MSGFILTER, apiserv->filter);
|
||||
|
||||
if (IS_DEBUG_OSPF_EVENT)
|
||||
zlog_debug("API: Delete apiserv(%p), total#(%d)",
|
||||
(void *)apiserv, apiserver_list->count);
|
||||
@ -904,6 +912,7 @@ int ospf_apiserver_unregister_opaque_type(struct ospf_apiserver *apiserv,
|
||||
/* Remove from list of registered opaque types */
|
||||
listnode_delete(apiserv->opaque_types, regtype);
|
||||
|
||||
XFREE(MTYPE_APISERVER, regtype);
|
||||
if (IS_DEBUG_OSPF_EVENT)
|
||||
zlog_debug(
|
||||
"API: Del LSA-type(%d)/Opaque-type(%d) from apiserv(%p), total#(%d)",
|
||||
|
@ -132,6 +132,10 @@ void ospf_opaque_finish(void)
|
||||
|
||||
ospf_ext_finish();
|
||||
|
||||
#ifdef SUPPORT_OSPF_API
|
||||
ospf_apiserver_term();
|
||||
#endif
|
||||
|
||||
ospf_sr_finish();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user