Skip to content

Commit

Permalink
mlxsw: core_linecards: Fix double memory deallocation in case of inva…
Browse files Browse the repository at this point in the history
…lid INI file

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: b217127 ("mlxsw: core_linecards: Add line card objects and implement provisioning")
Signed-off-by: Aleksandr Mishin <[email protected]>
Reviewed-by: Przemek Kitszel <[email protected]>
Reviewed-by: Ido Schimmel <[email protected]>
Reviewed-by: Michal Kubiak <[email protected]>
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Jakub Kicinski <[email protected]>
  • Loading branch information
Aleksandr Mishin authored and kuba-moo committed Jul 4, 2024
1 parent eec5969 commit 8ce34dc
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions drivers/net/ethernet/mellanox/mlxsw/core_linecards.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 8ce34dc

Please sign in to comment.