Skip to content

Commit b25a31b

Browse files
TaeheeYooummakynes
authored andcommitted
netfilter: nf_tables: add missing ->release_ops() in error path of newrule()
->release_ops() callback releases resources and this is used in error path. If nf_tables_newrule() fails after ->select_ops(), it should release resources. but it can not call ->destroy() because that should be called after ->init(). At this point, ->release_ops() should be used for releasing resources. Test commands: modprobe -rv xt_tcpudp iptables-nft -I INPUT -m tcp <-- error command lsmod Result: Module Size Used by xt_tcpudp 20480 2 <-- it should be 0 Fixes: b8e2040 ("netfilter: nft_compat: use .release_ops and remove list of extension") Signed-off-by: Taehee Yoo <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent 7c9abe1 commit b25a31b

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

net/netfilter/nf_tables_api.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2806,8 +2806,11 @@ static int nf_tables_newrule(struct net *net, struct sock *nlsk,
28062806
nf_tables_rule_release(&ctx, rule);
28072807
err1:
28082808
for (i = 0; i < n; i++) {
2809-
if (info[i].ops != NULL)
2809+
if (info[i].ops) {
28102810
module_put(info[i].ops->type->owner);
2811+
if (info[i].ops->type->release_ops)
2812+
info[i].ops->type->release_ops(info[i].ops);
2813+
}
28112814
}
28122815
kvfree(info);
28132816
return err;

0 commit comments

Comments
 (0)