Skip to content

Commit dfaa54c

Browse files
zhengchaoshaoBrian Maly
authored andcommitted
mlxsw: minimal: fix potential memory leak in mlxsw_m_linecards_init
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: 01328e2 ("mlxsw: minimal: Extend module to port mapping with slot index") Signed-off-by: Zhengchao Shao <[email protected]> Reviewed-by: Petr Machata <[email protected]> Reviewed-by: Ido Schimmel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]> Orabug: 35622106 (cherry picked from commit 08fc757) cherry-pick-repo=kernel/git/torvalds/linux.git unmodified-from-upstream: 08fc757 Signed-off-by: Mikhael Goikhman <[email protected]> Signed-off-by: Qing Huang <[email protected]> Reviewed-by: Devesh Sharma <[email protected]> Signed-off-by: Brian Maly <[email protected]>
1 parent 6304825 commit dfaa54c

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

drivers/net/ethernet/mellanox/mlxsw/minimal.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,7 @@ static int mlxsw_m_linecards_init(struct mlxsw_m *mlxsw_m)
417417
err_kmalloc_array:
418418
for (i--; i >= 0; i--)
419419
kfree(mlxsw_m->line_cards[i]);
420+
kfree(mlxsw_m->line_cards);
420421
err_kcalloc:
421422
kfree(mlxsw_m->ports);
422423
return err;

0 commit comments

Comments
 (0)