diff mbox series

[nft,1/7] nft_ctx_free: Fix for wrong argument passed to cache_release

Message ID 20171019081847.16171-2-phil@nwl.cc
State Accepted
Delegated to: Pablo Neira
Headers show
Series libnftables preparations | expand

Commit Message

Phil Sutter Oct. 19, 2017, 8:18 a.m. UTC
nft_ctx_free() should not refer to the global 'nft' variable, this will
break as soon as the function is moved away from main.c. In order to use
the cache reference from passed argument, the latter must not be const.

Signed-off-by: Phil Sutter <phil@nwl.cc>
---
 src/main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Pablo Neira Ayuso Oct. 20, 2017, 12:01 p.m. UTC | #1
On Thu, Oct 19, 2017 at 10:18:41AM +0200, Phil Sutter wrote:
> nft_ctx_free() should not refer to the global 'nft' variable, this will
> break as soon as the function is moved away from main.c. In order to use
> the cache reference from passed argument, the latter must not be const.

Applied, thanks.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox series

Patch

diff --git a/src/main.c b/src/main.c
index b59c932ad4299..1b26838058a4a 100644
--- a/src/main.c
+++ b/src/main.c
@@ -305,13 +305,13 @@  static struct nft_ctx *nft_ctx_new(uint32_t flags)
 	return ctx;
 }
 
-static void nft_ctx_free(const struct nft_ctx *ctx)
+static void nft_ctx_free(struct nft_ctx *ctx)
 {
 	if (ctx->nf_sock)
 		netlink_close_sock(ctx->nf_sock);
 
 	iface_cache_release();
-	cache_release(&nft->cache);
+	cache_release(&ctx->cache);
 	xfree(ctx);
 	nft_exit();
 }