netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] netfilter: Fix memleak in nf_nat_init
@ 2021-01-09 12:01 Dinghao Liu
  2021-01-09 12:12 ` Florian Westphal
  2021-01-10  8:39 ` Pablo Neira Ayuso
  0 siblings, 2 replies; 3+ messages in thread
From: Dinghao Liu @ 2021-01-09 12:01 UTC (permalink / raw)
  To: dinghao.liu, kjlu
  Cc: Pablo Neira Ayuso, Jozsef Kadlecsik, Florian Westphal,
	David S. Miller, Jakub Kicinski, netfilter-devel, coreteam,
	netdev, linux-kernel

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 <dinghao.liu@zju.edu.cn>
---
 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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] netfilter: Fix memleak in nf_nat_init
  2021-01-09 12:01 [PATCH] netfilter: Fix memleak in nf_nat_init Dinghao Liu
@ 2021-01-09 12:12 ` Florian Westphal
  2021-01-10  8:39 ` Pablo Neira Ayuso
  1 sibling, 0 replies; 3+ messages in thread
From: Florian Westphal @ 2021-01-09 12:12 UTC (permalink / raw)
  To: Dinghao Liu
  Cc: kjlu, Pablo Neira Ayuso, Jozsef Kadlecsik, Florian Westphal,
	David S. Miller, Jakub Kicinski, netfilter-devel, coreteam,
	netdev, linux-kernel

Dinghao Liu <dinghao.liu@zju.edu.cn> 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>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] netfilter: Fix memleak in nf_nat_init
  2021-01-09 12:01 [PATCH] netfilter: Fix memleak in nf_nat_init Dinghao Liu
  2021-01-09 12:12 ` Florian Westphal
@ 2021-01-10  8:39 ` Pablo Neira Ayuso
  1 sibling, 0 replies; 3+ messages in thread
From: Pablo Neira Ayuso @ 2021-01-10  8:39 UTC (permalink / raw)
  To: Dinghao Liu
  Cc: kjlu, Jozsef Kadlecsik, Florian Westphal, David S. Miller,
	Jakub Kicinski, netfilter-devel, coreteam, netdev, linux-kernel

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.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-01-10  8:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-09 12:01 [PATCH] netfilter: Fix memleak in nf_nat_init Dinghao Liu
2021-01-09 12:12 ` Florian Westphal
2021-01-10  8:39 ` Pablo Neira Ayuso

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).