Commit a577d868 authored by Christophe JAILLET's avatar Christophe JAILLET Committed by David S. Miller

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: 67f8b1dc ("net/mlx4_en: Refactor the XDP forwarding rings scheme")
Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: default avatarTariq Toukan <tariqt@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 97f3efb6
...@@ -3324,12 +3324,11 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port, ...@@ -3324,12 +3324,11 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port,
MAX_TX_RINGS, GFP_KERNEL); MAX_TX_RINGS, GFP_KERNEL);
if (!priv->tx_ring[t]) { if (!priv->tx_ring[t]) {
err = -ENOMEM; err = -ENOMEM;
goto err_free_tx; goto out;
} }
priv->tx_cq[t] = kzalloc(sizeof(struct mlx4_en_cq *) * priv->tx_cq[t] = kzalloc(sizeof(struct mlx4_en_cq *) *
MAX_TX_RINGS, GFP_KERNEL); MAX_TX_RINGS, GFP_KERNEL);
if (!priv->tx_cq[t]) { if (!priv->tx_cq[t]) {
kfree(priv->tx_ring[t]);
err = -ENOMEM; err = -ENOMEM;
goto out; goto out;
} }
...@@ -3582,11 +3581,6 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port, ...@@ -3582,11 +3581,6 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port,
return 0; return 0;
err_free_tx:
while (t--) {
kfree(priv->tx_ring[t]);
kfree(priv->tx_cq[t]);
}
out: out:
mlx4_en_destroy_netdev(dev); mlx4_en_destroy_netdev(dev);
return err; return err;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment