]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
mlxsw: spectrum: Fix memory leak in mlxsw_sp_flower_stats()
authorZilin Guan <zilin@seu.edu.cn>
Wed, 12 Nov 2025 05:21:14 +0000 (05:21 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 3 Dec 2025 11:45:20 +0000 (12:45 +0100)
commit607333b38f6b56d8959fb2783bf85ba1dc1a55fc
tree143a6afc186edd8f313f38d06fec6a426d26862d
parent1c74ded6a18a3030f327dc2f497dd9da3adfbc1a
mlxsw: spectrum: Fix memory leak in mlxsw_sp_flower_stats()

[ Upstream commit 407a06507c2358554958e8164dc97176feddcafc ]

The function mlxsw_sp_flower_stats() calls mlxsw_sp_acl_ruleset_get() to
obtain a ruleset reference. If the subsequent call to
mlxsw_sp_acl_rule_lookup() fails to find a rule, the function returns
an error without releasing the ruleset reference, causing a memory leak.

Fix this by using a goto to the existing error handling label, which
calls mlxsw_sp_acl_ruleset_put() to properly release the reference.

Fixes: 7c1b8eb175b69 ("mlxsw: spectrum: Add support for TC flower offload statistics")
Signed-off-by: Zilin Guan <zilin@seu.edu.cn>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Link: https://patch.msgid.link/20251112052114.1591695-1-zilin@seu.edu.cn
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c