[PATCH] netfilter: Fix memleak in nf_nat_init

Subsystems: netfilter, networking [general], the rest

STALE2043d

3 messages, 3 authors, 2021-01-10 · open the first message on its own page

[PATCH] netfilter: Fix memleak in nf_nat_init

From: Dinghao Liu <hidden>
Date: 2021-01-09 12:02:56

When register_pernet_subsys() fails, nf_nat_bysource
should be freed just like when nf_ct_extend_register()
fails.

Fixes: 1cd472bf036ca ("netfilter: nf_nat: add nat hook register functions to nf_nat")
Signed-off-by: Dinghao Liu <redacted>
---
 net/netfilter/nf_nat_core.c | 1 +
 1 file changed, 1 insertion(+)
diff --git a/net/netfilter/nf_nat_core.c b/net/netfilter/nf_nat_core.c
index ea923f8cf9c4..b7c3c902290f 100644
--- a/net/netfilter/nf_nat_core.c
+++ b/net/netfilter/nf_nat_core.c
@@ -1174,6 +1174,7 @@ static int __init nf_nat_init(void)
 	ret = register_pernet_subsys(&nat_net_ops);
 	if (ret < 0) {
 		nf_ct_extend_unregister(&nat_extend);
+		kvfree(nf_nat_bysource);
 		return ret;
 	}
 
-- 
2.17.1

Re: [PATCH] netfilter: Fix memleak in nf_nat_init

From: Florian Westphal <fw@strlen.de>
Date: 2021-01-09 12:13:41

Dinghao Liu [off-list ref] wrote:
When register_pernet_subsys() fails, nf_nat_bysource
should be freed just like when nf_ct_extend_register()
fails.
Acked-by: Florian Westphal <fw@strlen.de>

Re: [PATCH] netfilter: Fix memleak in nf_nat_init

From: Pablo Neira Ayuso <pablo@netfilter.org>
Date: 2021-01-10 08:40:53

On Sat, Jan 09, 2021 at 08:01:21PM +0800, Dinghao Liu wrote:
When register_pernet_subsys() fails, nf_nat_bysource
should be freed just like when nf_ct_extend_register()
fails.
Applied, thanks.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help