Skip to content

Commit 08fc757

Browse files
zhengchaoshaokuba-moo
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]>
1 parent 3cf62c8 commit 08fc757

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)