Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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: 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>

authored by

Zhengchao Shao and committed by
Jakub Kicinski
08fc7573 3cf62c81

+1
+1
drivers/net/ethernet/mellanox/mlxsw/minimal.c
··· 417 417 err_kmalloc_array: 418 418 for (i--; i >= 0; i--) 419 419 kfree(mlxsw_m->line_cards[i]); 420 + kfree(mlxsw_m->line_cards); 420 421 err_kcalloc: 421 422 kfree(mlxsw_m->ports); 422 423 return err;