aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2022-08-26 18:03:30 +0300
committerJakub Kicinski <kuba@kernel.org>2022-08-30 23:17:39 -0700
commit57688eb887af3db7f1d7f43f2c1babb548b01a34 (patch)
treeaea59d6a29206217ee613743982940bfe2af0d92
parentnet/mlx5e: Do not use err uninitialized in mlx5e_rep_add_meta_tunnel_rule() (diff)
downloadlinux-dev-57688eb887af3db7f1d7f43f2c1babb548b01a34.tar.xz
linux-dev-57688eb887af3db7f1d7f43f2c1babb548b01a34.zip
mlxsw: minimal: Return -ENOMEM on allocation failure
These error paths return success but they should return -ENOMEM. Fixes: 01328e23a476 ("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>
-rw-r--r--drivers/net/ethernet/mellanox/mlxsw/minimal.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/net/ethernet/mellanox/mlxsw/minimal.c b/drivers/net/ethernet/mellanox/mlxsw/minimal.c
index 7d3fa2883e8b..c7f7e49251f4 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/minimal.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/minimal.c
@@ -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++)