Skip to content

Commit

Permalink
mlxsw: minimal: Return -ENOMEM on allocation failure
Browse files Browse the repository at this point in the history
These error paths return success but they should return -ENOMEM.

Fixes: 01328e2 ("mlxsw: minimal: Extend module to port mapping with slot index")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Link: https://lore.kernel.org/r/YwjgwoJ3M7Kdq9VK@kili
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Dan Carpenter authored and Jakub Kicinski committed Aug 31, 2022
1 parent 92f97c0 commit 57688eb
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions drivers/net/ethernet/mellanox/mlxsw/minimal.c
Original file line number Diff line number Diff line change
Expand Up @@ -404,17 +404,21 @@ static int mlxsw_m_linecards_init(struct mlxsw_m *mlxsw_m)
mlxsw_m->line_cards = kcalloc(mlxsw_m->num_of_slots,
sizeof(*mlxsw_m->line_cards),
GFP_KERNEL);
if (!mlxsw_m->line_cards)
if (!mlxsw_m->line_cards) {
err = -ENOMEM;
goto err_kcalloc;
}

for (i = 0; i < mlxsw_m->num_of_slots; i++) {
mlxsw_m->line_cards[i] =
kzalloc(struct_size(mlxsw_m->line_cards[i],
module_to_port,
mlxsw_m->max_modules_per_slot),
GFP_KERNEL);
if (!mlxsw_m->line_cards[i])
if (!mlxsw_m->line_cards[i]) {
err = -ENOMEM;
goto err_kmalloc_array;
}

/* Invalidate the entries of module to local port mapping array. */
for (j = 0; j < mlxsw_m->max_modules_per_slot; j++)
Expand Down

0 comments on commit 57688eb

Please sign in to comment.