diff options
| author | Quentin Young <qlyoung@cumulusnetworks.com> | 2020-01-03 22:28:53 -0500 | 
|---|---|---|
| committer | Quentin Young <qlyoung@cumulusnetworks.com> | 2020-01-03 22:30:20 -0500 | 
| commit | 8b5c4dce07e6f8fa7f984945d6121e6999072f3d (patch) | |
| tree | 39c4d6611e949ee734fe8be60de7e4be5a3eb3c3 /zebra/zebra_pbr.c | |
| parent | b833cc1ff473e5de43a6c33b520024c943db180c (diff) | |
zebra: fix iptable memleak, fix free funcs
- Fix iptable freeing code to free malloc'd list
- malloc iptable in zapi handler and use those functions to free it when
  done to fix a linked list memleak
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Diffstat (limited to 'zebra/zebra_pbr.c')
| -rw-r--r-- | zebra/zebra_pbr.c | 13 | 
1 files changed, 8 insertions, 5 deletions
diff --git a/zebra/zebra_pbr.c b/zebra/zebra_pbr.c index e24d2e2b42..0c3adcdfa1 100644 --- a/zebra/zebra_pbr.c +++ b/zebra/zebra_pbr.c @@ -345,11 +345,13 @@ void zebra_pbr_iptable_free(void *arg)  	iptable = (struct zebra_pbr_iptable *)arg;  	hook_call(zebra_pbr_iptable_update, 0, iptable); -	for (ALL_LIST_ELEMENTS(iptable->interface_name_list, -					node, nnode, name)) { -		XFREE(MTYPE_PBR_IPTABLE_IFNAME, name); -		list_delete_node(iptable->interface_name_list, -				 node); +	if (iptable->interface_name_list) { +		for (ALL_LIST_ELEMENTS(iptable->interface_name_list, node, +				       nnode, name)) { +			XFREE(MTYPE_PBR_IPTABLE_IFNAME, name); +			list_delete_node(iptable->interface_name_list, node); +		} +		list_delete(&iptable->interface_name_list);  	}  	XFREE(MTYPE_TMP, iptable);  } @@ -688,6 +690,7 @@ void zebra_pbr_del_iptable(struct zebra_pbr_iptable *iptable)  			list_delete_node(iptable->interface_name_list,  					 node);  		} +		list_delete(&iptable->interface_name_list);  		XFREE(MTYPE_TMP, lookup);  	} else  		zlog_debug("%s: IPTable being deleted we know nothing about",  | 
