Skip to content

Commit d7c03a9

Browse files
wenxuummakynes
authored andcommitted
netfilter: nf_tables: check if bind callback fails and unbind if hook registration fails
Undo the callback binding before unregistering the existing hooks. This should also check for error of the bind setup call. Fixes: c29f74e ("netfilter: nf_flow_table: hardware offload support") Signed-off-by: wenxu <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent 63b48c7 commit d7c03a9

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

net/netfilter/nf_tables_api.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6006,12 +6006,20 @@ static int nft_register_flowtable_net_hooks(struct net *net,
60066006
}
60076007
}
60086008

6009-
flowtable->data.type->setup(&flowtable->data, hook->ops.dev,
6010-
FLOW_BLOCK_BIND);
6011-
err = nf_register_net_hook(net, &hook->ops);
6009+
err = flowtable->data.type->setup(&flowtable->data,
6010+
hook->ops.dev,
6011+
FLOW_BLOCK_BIND);
60126012
if (err < 0)
60136013
goto err_unregister_net_hooks;
60146014

6015+
err = nf_register_net_hook(net, &hook->ops);
6016+
if (err < 0) {
6017+
flowtable->data.type->setup(&flowtable->data,
6018+
hook->ops.dev,
6019+
FLOW_BLOCK_UNBIND);
6020+
goto err_unregister_net_hooks;
6021+
}
6022+
60156023
i++;
60166024
}
60176025

0 commit comments

Comments
 (0)