Call nft_data_release() to release the element keys otherwise this might leak chain reference counter. Fixes: 7b225d0b5c6d ("netfilter: nf_tables: add NFTA_SET_ELEM_KEY_END attribute") Signed-off-by: Pablo Neira Ayuso <pablo@xxxxxxxxxxxxx> --- net/netfilter/nf_tables_api.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c index 04dc6a349759..769e0b60434d 100644 --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c @@ -6344,7 +6344,7 @@ static int nft_del_setelem(struct nft_ctx *ctx, struct nft_set *set, err = nft_setelem_parse_key(ctx, set, &elem.key_end.val, nla[NFTA_SET_ELEM_KEY_END]); if (err < 0) - return err; + goto fail_elem; nft_set_ext_add_length(&tmpl, NFT_SET_EXT_KEY_END, set->klen); } @@ -6354,7 +6354,7 @@ static int nft_del_setelem(struct nft_ctx *ctx, struct nft_set *set, GFP_KERNEL_ACCOUNT); if (IS_ERR(elem.priv)) { err = PTR_ERR(elem.priv); - goto fail_elem; + goto fail_elem_key_end; } ext = nft_set_elem_ext(set, elem.priv); @@ -6379,8 +6379,11 @@ static int nft_del_setelem(struct nft_ctx *ctx, struct nft_set *set, kfree(trans); fail_trans: kfree(elem.priv); +fail_elem_key_end: + nft_data_release(&elem.key_end.val, NFT_DATA_VALUE); fail_elem: nft_data_release(&elem.key.val, NFT_DATA_VALUE); + return err; } -- 2.30.2