diff mbox series

[v5,5/5] x_tables: exit_net cleanup check added

Message ID 0b798b5c-74c1-386f-805c-9a1be2befc72@virtuozzo.com
State Accepted
Delegated to: Pablo Neira
Headers show
Series netfilter: exit_net checks for objects initialized in net_init hook | expand

Commit Message

Vasily Averin Nov. 12, 2017, 11:35 a.m. UTC
Be sure that xt.tables array initialized in net_init hook was return
to initial state.

Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
---
 net/netfilter/x_tables.c | 9 +++++++++
 1 file changed, 9 insertions(+)
diff mbox series

Patch

diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c
index d8571f4..02c1abb 100644
--- a/net/netfilter/x_tables.c
+++ b/net/netfilter/x_tables.c
@@ -1714,8 +1714,17 @@  static int __net_init xt_net_init(struct net *net)
 	return 0;
 }
 
+static void __net_exit xt_net_exit(struct net *net)
+{
+	int i;
+
+	for (i = 0; i < NFPROTO_NUMPROTO; i++)
+		WARN_ON_ONCE(!list_empty(&net->xt.tables[i]));
+}
+
 static struct pernet_operations xt_net_ops = {
 	.init = xt_net_init,
+	.exit = xt_net_exit,
 };
 
 static int __init xt_init(void)