Skip to content

Commit 6cafaf4

Browse files
Liping Zhangummakynes
authored andcommitted
netfilter: nf_tables: fix memory leak if expr init fails
If expr init fails then we need to free it. So when the user add a nft rule as follows: # nft add rule filter input tcp dport 22 flow table ssh \ { ip saddr limit rate 0/second } memory leak will happen. Signed-off-by: Liping Zhang <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent acd43fe commit 6cafaf4

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

net/netfilter/nf_tables_api.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1724,9 +1724,11 @@ struct nft_expr *nft_expr_init(const struct nft_ctx *ctx,
17241724

17251725
err = nf_tables_newexpr(ctx, &info, expr);
17261726
if (err < 0)
1727-
goto err2;
1727+
goto err3;
17281728

17291729
return expr;
1730+
err3:
1731+
kfree(expr);
17301732
err2:
17311733
module_put(info.ops->type->owner);
17321734
err1:

0 commit comments

Comments
 (0)