mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 10:31:46 +09:00
mlxsw: minimal: fix potential memory leak in mlxsw_m_linecards_init
[ Upstream commit08fc75735f] 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:01328e23a4("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>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
0b24d3e4b9
commit
d4f5b1dd81
@@ -430,6 +430,7 @@ static int mlxsw_m_linecards_init(struct mlxsw_m *mlxsw_m)
|
||||
err_kmalloc_array:
|
||||
for (i--; i >= 0; i--)
|
||||
kfree(mlxsw_m->line_cards[i]);
|
||||
kfree(mlxsw_m->line_cards);
|
||||
err_kcalloc:
|
||||
kfree(mlxsw_m->ports);
|
||||
return err;
|
||||
|
||||
Reference in New Issue
Block a user