[lvc-project] [PATCH net v2] mlxsw: core_linecards: Fix double memory deallocation in case of invalid INI file
Aleksandr Mishin
amishin at t-argos.ru
Wed Jul 3 23:32:51 MSK 2024
In case of invalid INI file mlxsw_linecard_types_init() deallocates memory
but doesn't reset pointer to NULL and returns 0. In case of any error
occurred after mlxsw_linecard_types_init() call, mlxsw_linecards_init()
calls mlxsw_linecard_types_fini() which performs memory deallocation again.
Add pointer reset to NULL.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Fixes: b217127e5e4e ("mlxsw: core_linecards: Add line card objects and implement provisioning")
Signed-off-by: Aleksandr Mishin <amishin at t-argos.ru>
Reviewed-by: Przemek Kitszel <przemyslaw.kitszel at intel.com>
Reviewed-by: Ido Schimmel <idosch at nvidia.com>
---
v2:
- fix few typos in comment as suggested by Przemek and Ido
- add Reviewed-by: Przemek Kitszel <przemyslaw.kitszel at intel.com>
(https://lore.kernel.org/all/c631fc5e-1cc6-467a-963a-69ef03c20f40@intel.com/)
- add Reviewed-by: Ido Schimmel <idosch at nvidia.com>
(https://lore.kernel.org/all/ZoWJzqaRJKjtTlNO@shredder.mtl.com/)
v1: https://lore.kernel.org/all/20240702103352.15315-1-amishin@t-argos.ru/
drivers/net/ethernet/mellanox/mlxsw/core_linecards.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_linecards.c b/drivers/net/ethernet/mellanox/mlxsw/core_linecards.c
index 025e0db983fe..b032d5a4b3b8 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/core_linecards.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_linecards.c
@@ -1484,6 +1484,7 @@ static int mlxsw_linecard_types_init(struct mlxsw_core *mlxsw_core,
vfree(types_info->data);
err_data_alloc:
kfree(types_info);
+ linecards->types_info = NULL;
return err;
}
--
2.30.2
More information about the lvc-project
mailing list