]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
net/mlx4_en: Fix an error handling path in 'mlx4_en_init_netdev()'
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Thu, 10 May 2018 07:06:04 +0000 (09:06 +0200)
committerStefan Bader <stefan.bader@canonical.com>
Tue, 14 Aug 2018 10:26:31 +0000 (12:26 +0200)
BugLink: http://bugs.launchpad.net/bugs/1780858
[ Upstream commit a577d868b768a3baf16cdd4841ab8cfb165521d6 ]

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 <christophe.jaillet@wanadoo.fr>
Reviewed-by: Tariq Toukan <tariqt@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
drivers/net/ethernet/mellanox/mlx4/en_netdev.c

index 21bc17fa38546f7a41a09aa6072db393000daef9..90223ea412f1c6f81d8bf3c2de059879094367a2 100644 (file)
@@ -3319,12 +3319,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;
                }
@@ -3577,11 +3576,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;