net/mlx5e: Avoid NULL pointer access in case of configuration failure
authorAchiad Shochat <achiad@mellanox.com>
Tue, 3 Nov 2015 06:07:18 +0000 (08:07 +0200)
committerDavid S. Miller <davem@davemloft.net>
Tue, 3 Nov 2015 15:41:50 +0000 (10:41 -0500)
In case a configuration operation that involves closing and re-opening
resources (e.g RX/TX queue size change) fails at the re-opening stage
these resources will remain closed.
So when executing (following) configuration operations (e.g ifconfig
down) we cannot assume that these resources are available.

Signed-off-by: Achiad Shochat <achiad@mellanox.com>
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlx5/core/en_main.c

index bb801a9bbd42508668ddb0fad8ba49a74c1db769..9df6f9ae9bb5a80bdae7b18380e8aec51c68408c 100644 (file)
@@ -1404,6 +1404,12 @@ int mlx5e_close_locked(struct net_device *netdev)
 {
        struct mlx5e_priv *priv = netdev_priv(netdev);
 
+       /* May already be CLOSED in case a previous configuration operation
+        * (e.g RX/TX queue size change) that involves close&open failed.
+        */
+       if (!test_bit(MLX5E_STATE_OPENED, &priv->state))
+               return 0;
+
        clear_bit(MLX5E_STATE_OPENED, &priv->state);
 
        mlx5e_redirect_rqts(priv);