>From a6e05e56907673e21948c6ae53f45494b25fc0aa Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Fri, 15 Nov 2019 00:22:55 +0100 Subject: [PATCH] netfilter: nf_tables: unbind callbacks if flowtable hook registration fails Undo the callback binding before unregistering the existing hooks. Fixes: c29f74e0df7a ("netfilter: nf_flow_table: hardware offload support") Reported-by: wenxu Signed-off-by: Pablo Neira Ayuso --- net/netfilter/nf_tables_api.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c index 2dc636faa322..ad3882e14e82 100644 --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c @@ -5998,8 +5998,12 @@ static int nft_register_flowtable_net_hooks(struct net *net, flowtable->data.type->setup(&flowtable->data, hook->ops.dev, FLOW_BLOCK_BIND); err = nf_register_net_hook(net, &hook->ops); - if (err < 0) + if (err < 0) { + flowtable->data.type->setup(&flowtable->data, + hook->ops.dev, + FLOW_BLOCK_UNBIND); goto err_unregister_net_hooks; + } i++; } -- 2.11.0