Skip to content

Commit 4ca041f

Browse files
Colin Ian Kingummakynes
authored andcommitted
netfilter: nf_tables: Fix dereference of null pointer flow
In the case where chain->flags & NFT_CHAIN_HW_OFFLOAD is false then nft_flow_rule_create is not called and flow is NULL. The subsequent error handling execution via label err_destroy_flow_rule will lead to a null pointer dereference on flow when calling nft_flow_rule_destroy. Since the error path to err_destroy_flow_rule has to cater for null and non-null flows, only call nft_flow_rule_destroy if flow is non-null to fix this issue. Addresses-Coverity: ("Explicity null dereference") Fixes: 3c5e446 ("netfilter: nf_tables: memleak in hw offload abort path") Signed-off-by: Colin Ian King <colin.king@canonical.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
1 parent e15d4cd commit 4ca041f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

net/netfilter/nf_tables_api.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3446,7 +3446,8 @@ static int nf_tables_newrule(struct sk_buff *skb, const struct nfnl_info *info,
34463446
return 0;
34473447

34483448
err_destroy_flow_rule:
3449-
nft_flow_rule_destroy(flow);
3449+
if (flow)
3450+
nft_flow_rule_destroy(flow);
34503451
err_release_rule:
34513452
nf_tables_rule_release(&ctx, rule);
34523453
err_release_expr:

0 commit comments

Comments
 (0)