mlxsw: minimal: fix potential memory leak in mlxsw_m_linecards_init
authorZhengchao Shao <shaozhengchao@huawei.com>
Fri, 30 Jun 2023 01:26:47 +0000 (09:26 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 19 Jul 2023 14:22:03 +0000 (16:22 +0200)
commitd4f5b1dd816dccd4ee6bb60b2a81a3d4373636a9
tree527b47d0d183b394dd0dbd84555b13d24b6e5022
parent0b24d3e4b989caf1f4e34eba14659d2a7ac468b2
mlxsw: minimal: fix potential memory leak in mlxsw_m_linecards_init

[ Upstream commit 08fc75735fda3be97194bfbf3c899c87abb3d0fe ]

The line cards array is not freed in the error path of
mlxsw_m_linecards_init(), which can lead to a memory leak. Fix by
freeing the array in the error path, thereby making the error path
identical to mlxsw_m_linecards_fini().

Fixes: 01328e23a476 ("mlxsw: minimal: Extend module to port mapping with slot index")
Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
Reviewed-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Link: https://lore.kernel.org/r/20230630012647.1078002-1-shaozhengchao@huawei.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/mellanox/mlxsw/minimal.c