]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
nft: Clear all lists in nft_fini()
authorPhil Sutter <phil@nwl.cc>
Mon, 4 May 2020 17:20:52 +0000 (19:20 +0200)
committerPhil Sutter <phil@nwl.cc>
Mon, 11 May 2020 12:28:29 +0000 (14:28 +0200)
Remove and free any pending entries in obj_list and err_list as well. To
get by without having to declare list-specific cursors, use generic
list_head types and call list_entry() explicitly.

Signed-off-by: Phil Sutter <phil@nwl.cc>
iptables/nft.c

index 6503259eb443e180dabd769e0736b4ba372bdce5..addde1b53f37ef9d3e8f3f44626e29e473b8fd39 100644 (file)
@@ -850,10 +850,16 @@ int nft_init(struct nft_handle *h, int family, const struct builtin_table *t)
 
 void nft_fini(struct nft_handle *h)
 {
-       struct nft_cmd *cmd, *next;
+       struct list_head *pos, *n;
 
-       list_for_each_entry_safe(cmd, next, &h->cmd_list, head)
-               nft_cmd_free(cmd);
+       list_for_each_safe(pos, n, &h->cmd_list)
+               nft_cmd_free(list_entry(pos, struct nft_cmd, head));
+
+       list_for_each_safe(pos, n, &h->obj_list)
+               batch_obj_del(h, list_entry(pos, struct obj_update, head));
+
+       list_for_each_safe(pos, n, &h->err_list)
+               mnl_err_list_free(list_entry(pos, struct mnl_err, head));
 
        nft_release_cache(h);
        mnl_socket_close(h->nl);