Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net/mlx4_en: fix a memory leak bug

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: 4931c6ef04b4 ("net/mlx4_en: Optimized single ring steering")
Signed-off-by: Wenwen Wang <wenwen@cs.uga.edu>
Reviewed-by: Tariq Toukan <tariqt@mellanox.com>
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>

authored by

Wenwen Wang and committed by
Jakub Kicinski
48ec7014 66cf4710

+2 -1
+2 -1
drivers/net/ethernet/mellanox/mlx4/en_rx.c
··· 1187 1187 err = mlx4_qp_alloc(mdev->dev, priv->base_qpn, rss_map->indir_qp); 1188 1188 if (err) { 1189 1189 en_err(priv, "Failed to allocate RSS indirection QP\n"); 1190 - goto rss_err; 1190 + goto qp_alloc_err; 1191 1191 } 1192 1192 1193 1193 rss_map->indir_qp->event = mlx4_en_sqp_event; ··· 1241 1241 MLX4_QP_STATE_RST, NULL, 0, 0, rss_map->indir_qp); 1242 1242 mlx4_qp_remove(mdev->dev, rss_map->indir_qp); 1243 1243 mlx4_qp_free(mdev->dev, rss_map->indir_qp); 1244 + qp_alloc_err: 1244 1245 kfree(rss_map->indir_qp); 1245 1246 rss_map->indir_qp = NULL; 1246 1247 rss_err: