]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
netfilter: nf_tables: Fix a memory leak in nf_tables_updchain
authorQuan Tian <tianquan23@gmail.com>
Wed, 6 Mar 2024 17:24:02 +0000 (01:24 +0800)
committerSasha Levin <sashal@kernel.org>
Tue, 26 Mar 2024 22:20:13 +0000 (18:20 -0400)
commit79846fdcc548d617b0b321addc6a3821d3b75b20
treedb8db4fe482ef0d0ab5cea1ae594617d4145199f
parent16f55acf58e2681300c2abfef322f4495a6f1397
netfilter: nf_tables: Fix a memory leak in nf_tables_updchain

[ Upstream commit 7eaf837a4eb5f74561e2486972e7f5184b613f6e ]

If nft_netdev_register_hooks() fails, the memory associated with
nft_stats is not freed, causing a memory leak.

This patch fixes it by moving nft_stats_alloc() down after
nft_netdev_register_hooks() succeeds.

Fixes: b9703ed44ffb ("netfilter: nf_tables: support for adding new devices to an existing netdev chain")
Signed-off-by: Quan Tian <tianquan23@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/netfilter/nf_tables_api.c