Skip to content

Commit a577d86

Browse files
tititiou36davem330
authored andcommitted
net/mlx4_en: Fix an error handling path in 'mlx4_en_init_netdev()'
If an error occurs, 'mlx4_en_destroy_netdev()' is called. It then calls 'mlx4_en_free_resources()' which does the needed resources cleanup. So, doing some explicit kfree in the error handling path would lead to some double kfree. Simplify code to avoid such a case. Fixes: 67f8b1d ("net/mlx4_en: Refactor the XDP forwarding rings scheme") Signed-off-by: Christophe JAILLET <[email protected]> Reviewed-by: Tariq Toukan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 97f3efb commit a577d86

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3324,12 +3324,11 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port,
33243324
MAX_TX_RINGS, GFP_KERNEL);
33253325
if (!priv->tx_ring[t]) {
33263326
err = -ENOMEM;
3327-
goto err_free_tx;
3327+
goto out;
33283328
}
33293329
priv->tx_cq[t] = kzalloc(sizeof(struct mlx4_en_cq *) *
33303330
MAX_TX_RINGS, GFP_KERNEL);
33313331
if (!priv->tx_cq[t]) {
3332-
kfree(priv->tx_ring[t]);
33333332
err = -ENOMEM;
33343333
goto out;
33353334
}
@@ -3582,11 +3581,6 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port,
35823581

35833582
return 0;
35843583

3585-
err_free_tx:
3586-
while (t--) {
3587-
kfree(priv->tx_ring[t]);
3588-
kfree(priv->tx_cq[t]);
3589-
}
35903584
out:
35913585
mlx4_en_destroy_netdev(dev);
35923586
return err;

0 commit comments

Comments
 (0)