Skip to content

Commit 7d70984

Browse files
committed
netfilter: nft_connlimit: memleak if nf_ct_netns_get() fails
Check if nf_ct_netns_get() fails then release the limit object previously allocated via kmalloc(). Fixes: 37f319f ("netfilter: nft_connlimit: move stateful fields out of expression data") Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
1 parent fe75e84 commit 7d70984

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

net/netfilter/nft_connlimit.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ static int nft_connlimit_do_init(const struct nft_ctx *ctx,
6262
{
6363
bool invert = false;
6464
u32 flags, limit;
65+
int err;
6566

6667
if (!tb[NFTA_CONNLIMIT_COUNT])
6768
return -EINVAL;
@@ -84,7 +85,15 @@ static int nft_connlimit_do_init(const struct nft_ctx *ctx,
8485
priv->limit = limit;
8586
priv->invert = invert;
8687

87-
return nf_ct_netns_get(ctx->net, ctx->family);
88+
err = nf_ct_netns_get(ctx->net, ctx->family);
89+
if (err < 0)
90+
goto err_netns;
91+
92+
return 0;
93+
err_netns:
94+
kfree(priv->list);
95+
96+
return err;
8897
}
8998

9099
static void nft_connlimit_do_destroy(const struct nft_ctx *ctx,

0 commit comments

Comments
 (0)