Skip to content

Commit

Permalink
net/mlx4_en: Fix an error handling path in 'mlx4_en_init_netdev()'
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
tititiou36 authored and davem330 committed May 10, 2018
1 parent 97f3efb commit a577d86
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions drivers/net/ethernet/mellanox/mlx4/en_netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
goto err_free_tx;
goto out;
}
priv->tx_cq[t] = kzalloc(sizeof(struct mlx4_en_cq *) *
MAX_TX_RINGS, GFP_KERNEL);
if (!priv->tx_cq[t]) {
kfree(priv->tx_ring[t]);
err = -ENOMEM;
goto out;
}
Expand Down Expand Up @@ -3582,11 +3581,6 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port,

return 0;

err_free_tx:
while (t--) {
kfree(priv->tx_ring[t]);
kfree(priv->tx_cq[t]);
}
out:
mlx4_en_destroy_netdev(dev);
return err;
Expand Down

0 comments on commit a577d86

Please sign in to comment.