Commit 57688eb8 authored by Dan Carpenter's avatar Dan Carpenter Committed by Jakub Kicinski

mlxsw: minimal: Return -ENOMEM on allocation failure

These error paths return success but they should return -ENOMEM.

Fixes: 01328e23 ("mlxsw: minimal: Extend module to port mapping with slot index")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: default avatarPetr Machata <petrm@nvidia.com>
Reviewed-by: default avatarIdo Schimmel <idosch@nvidia.com>
Link: https://lore.kernel.org/r/YwjgwoJ3M7Kdq9VK@kiliSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 92f97c00
......@@ -404,8 +404,10 @@ 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] =
......@@ -413,8 +415,10 @@ static int mlxsw_m_linecards_init(struct mlxsw_m *mlxsw_m)
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++)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment