]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
netfilter: nf_tables: fix memory leak in nf_tables_newrule()
authorZilin Guan <zilin@seu.edu.cn>
Wed, 24 Dec 2025 12:48:26 +0000 (12:48 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 19 Jan 2026 12:10:16 +0000 (13:10 +0100)
commit92d17b97479cd9dfc7ab376da7cc8b57b2e6a888
treedd826349e9851f8d1b1b9ebd7906235176feb6b9
parentd65b19f34c2adf485409b8134d91fc05fe8c10fd
netfilter: nf_tables: fix memory leak in nf_tables_newrule()

[ Upstream commit d077e8119ddbb4fca67540f1a52453631a47f221 ]

In nf_tables_newrule(), if nft_use_inc() fails, the function jumps to
the err_release_rule label without freeing the allocated flow, leading
to a memory leak.

Fix this by adding a new label err_destroy_flow and jumping to it when
nft_use_inc() fails. This ensures that the flow is properly released
in this error case.

Fixes: 1689f25924ada ("netfilter: nf_tables: report use refcount overflow")
Signed-off-by: Zilin Guan <zilin@seu.edu.cn>
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/netfilter/nf_tables_api.c