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: 67f8b1dcb9ee ("net/mlx4_en: Refactor the XDP forwarding rings scheme")
Signed-off-by: Christophe JAILLET <redacted>
---
v1 -> v2 : rewrite the fix as explained by Tariq Toukan
(this 2nd version may have been posted twice, once without the
v2 tag. PLease ignore the first one)
---
drivers/net/ethernet/mellanox/mlx4/en_netdev.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
@@ -3324,12 +3324,11 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port,MAX_TX_RINGS,GFP_KERNEL);if(!priv->tx_ring[t]){err=-ENOMEM;-gotoerr_free_tx;+gotoout;}priv->tx_cq[t]=kzalloc(sizeof(structmlx4_en_cq*)*MAX_TX_RINGS,GFP_KERNEL);if(!priv->tx_cq[t]){-kfree(priv->tx_ring[t]);err=-ENOMEM;gotoout;}
@@ -3582,11 +3581,6 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port,return0;-err_free_tx:-while(t--){-kfree(priv->tx_ring[t]);-kfree(priv->tx_cq[t]);-}out:mlx4_en_destroy_netdev(dev);returnerr;
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: 67f8b1dcb9ee ("net/mlx4_en: Refactor the XDP forwarding rings scheme")
Signed-off-by: Christophe JAILLET <redacted>
---
v1 -> v2 : rewrite the fix as explained by Tariq Toukan
(this 2nd version may have been posted twice, once without the
v2 tag. PLease ignore the first one)
---
drivers/net/ethernet/mellanox/mlx4/en_netdev.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
@@ -3324,12 +3324,11 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port,MAX_TX_RINGS,GFP_KERNEL);if(!priv->tx_ring[t]){err=-ENOMEM;-gotoerr_free_tx;+gotoout;}priv->tx_cq[t]=kzalloc(sizeof(structmlx4_en_cq*)*MAX_TX_RINGS,GFP_KERNEL);if(!priv->tx_cq[t]){-kfree(priv->tx_ring[t]);err=-ENOMEM;gotoout;}
@@ -3582,11 +3581,6 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port,return0;-err_free_tx:-while(t--){-kfree(priv->tx_ring[t]);-kfree(priv->tx_cq[t]);-}out:mlx4_en_destroy_netdev(dev);returnerr;
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: 67f8b1dcb9ee ("net/mlx4_en: Refactor the XDP forwarding rings scheme")
Signed-off-by: Christophe JAILLET <redacted>