* [PATCH RESEND,net,v2] mlxsw: minimal: fix potential memory leak in mlxsw_m_linecards_init
@ 2023-06-30 1:26 Zhengchao Shao
2023-06-30 2:20 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: Zhengchao Shao @ 2023-06-30 1:26 UTC (permalink / raw)
To: netdev, davem, edumazet, kuba, pabeni
Cc: idosch, petrm, jiri, vadimp, weiyongjun1, yuehaibing, shaozhengchao
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>
---
v2: modify commit message.
---
drivers/net/ethernet/mellanox/mlxsw/minimal.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/net/ethernet/mellanox/mlxsw/minimal.c b/drivers/net/ethernet/mellanox/mlxsw/minimal.c
index 6b56eadd736e..6b98c3287b49 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/minimal.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/minimal.c
@@ -417,6 +417,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;
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH RESEND,net,v2] mlxsw: minimal: fix potential memory leak in mlxsw_m_linecards_init
2023-06-30 1:26 [PATCH RESEND,net,v2] mlxsw: minimal: fix potential memory leak in mlxsw_m_linecards_init Zhengchao Shao
@ 2023-06-30 2:20 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-06-30 2:20 UTC (permalink / raw)
To: Zhengchao Shao
Cc: netdev, davem, edumazet, kuba, pabeni, idosch, petrm, jiri,
vadimp, weiyongjun1, yuehaibing
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Fri, 30 Jun 2023 09:26:47 +0800 you wrote:
> 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>
>
> [...]
Here is the summary with links:
- [RESEND,net,v2] mlxsw: minimal: fix potential memory leak in mlxsw_m_linecards_init
https://git.kernel.org/netdev/net/c/08fc75735fda
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-06-30 2:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-30 1:26 [PATCH RESEND,net,v2] mlxsw: minimal: fix potential memory leak in mlxsw_m_linecards_init Zhengchao Shao
2023-06-30 2:20 ` patchwork-bot+netdevbpf
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.