nft_init() should rollback all changes it made during init
when something goes wrong, callers should NOT call nft_fini()
on error.
Note that this change is irrelevant at the moment, all users
call exit() on failure.
Signed-off-by: Florian Westphal <fw@strlen.de>
if (h->nl == NULL)
return -1;
- if (mnl_socket_bind(h->nl, 0, MNL_SOCKET_AUTOPID) < 0)
+ if (mnl_socket_bind(h->nl, 0, MNL_SOCKET_AUTOPID) < 0) {
+ mnl_socket_close(h->nl);
return -1;
+ }
h->portid = mnl_socket_get_portid(h->nl);
h->tables = t;
xtables_globals.program_name,
xtables_globals.program_version,
strerror(errno));
- nft_fini(&h);
exit(EXIT_FAILURE);
}