Skip to content

Commit ea4b1cf

Browse files
wenwenwang1Sasha Levin
authored and
Sasha Levin
committed
net/mlx4_en: fix a memory leak bug
[ Upstream commit 48ec701 ] In mlx4_en_config_rss_steer(), 'rss_map->indir_qp' is allocated through kzalloc(). After that, mlx4_qp_alloc() is invoked to configure RSS indirection. However, if mlx4_qp_alloc() fails, the allocated 'rss_map->indir_qp' is not deallocated, leading to a memory leak bug. To fix the above issue, add the 'qp_alloc_err' label to free 'rss_map->indir_qp'. Fixes: 4931c6e ("net/mlx4_en: Optimized single ring steering") Signed-off-by: Wenwen Wang <[email protected]> Reviewed-by: Tariq Toukan <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 4c3e9cd commit ea4b1cf

File tree

1 file changed

+2
-1
lines changed
  • drivers/net/ethernet/mellanox/mlx4

1 file changed

+2
-1
lines changed

drivers/net/ethernet/mellanox/mlx4/en_rx.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1187,7 +1187,7 @@ int mlx4_en_config_rss_steer(struct mlx4_en_priv *priv)
11871187
err = mlx4_qp_alloc(mdev->dev, priv->base_qpn, rss_map->indir_qp);
11881188
if (err) {
11891189
en_err(priv, "Failed to allocate RSS indirection QP\n");
1190-
goto rss_err;
1190+
goto qp_alloc_err;
11911191
}
11921192

11931193
rss_map->indir_qp->event = mlx4_en_sqp_event;
@@ -1241,6 +1241,7 @@ int mlx4_en_config_rss_steer(struct mlx4_en_priv *priv)
12411241
MLX4_QP_STATE_RST, NULL, 0, 0, rss_map->indir_qp);
12421242
mlx4_qp_remove(mdev->dev, rss_map->indir_qp);
12431243
mlx4_qp_free(mdev->dev, rss_map->indir_qp);
1244+
qp_alloc_err:
12441245
kfree(rss_map->indir_qp);
12451246
rss_map->indir_qp = NULL;
12461247
rss_err:

0 commit comments

Comments
 (0)