Skip to content

Commit b6193d7

Browse files
author
Saeed Mahameed
committed
net/mlx5e: Fix error handling in mlx5e_refresh_tirs
Allocation failure is outside the critical lock section and should return immediately rather than jumping to the unlock section. Also unlock as soon as required and remove the now redundant jump label. Fixes: 80a2a90 ("net/mlx5e: Add a lock on tir list") Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
1 parent 3685919 commit b6193d7

1 file changed

Lines changed: 4 additions & 7 deletions

File tree

drivers/net/ethernet/mellanox/mlx5/core/en_common.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,8 @@ int mlx5e_refresh_tirs(struct mlx5e_priv *priv, bool enable_uc_lb,
150150

151151
inlen = MLX5_ST_SZ_BYTES(modify_tir_in);
152152
in = kvzalloc(inlen, GFP_KERNEL);
153-
if (!in) {
154-
err = -ENOMEM;
155-
goto out;
156-
}
153+
if (!in)
154+
return -ENOMEM;
157155

158156
if (enable_uc_lb)
159157
lb_flags = MLX5_TIRC_SELF_LB_BLOCK_BLOCK_UNICAST;
@@ -171,14 +169,13 @@ int mlx5e_refresh_tirs(struct mlx5e_priv *priv, bool enable_uc_lb,
171169
tirn = tir->tirn;
172170
err = mlx5_core_modify_tir(mdev, tirn, in);
173171
if (err)
174-
goto out;
172+
break;
175173
}
174+
mutex_unlock(&mdev->mlx5e_res.hw_objs.td.list_lock);
176175

177-
out:
178176
kvfree(in);
179177
if (err)
180178
netdev_err(priv->netdev, "refresh tir(0x%x) failed, %d\n", tirn, err);
181-
mutex_unlock(&mdev->mlx5e_res.hw_objs.td.list_lock);
182179

183180
return err;
184181
}

0 commit comments

Comments
 (0)