提交 6cafaf47 编写于 作者: L Liping Zhang 提交者: Pablo Neira Ayuso

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: NLiping Zhang <liping.zhang@spreadtrum.com>
Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
上级 acd43fe8
...@@ -1724,9 +1724,11 @@ struct nft_expr *nft_expr_init(const struct nft_ctx *ctx, ...@@ -1724,9 +1724,11 @@ struct nft_expr *nft_expr_init(const struct nft_ctx *ctx,
err = nf_tables_newexpr(ctx, &info, expr); err = nf_tables_newexpr(ctx, &info, expr);
if (err < 0) if (err < 0)
goto err2; goto err3;
return expr; return expr;
err3:
kfree(expr);
err2: err2:
module_put(info.ops->type->owner); module_put(info.ops->type->owner);
err1: err1:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册