net/mlx4_core: Check device state before unregistering it
authorAlex Vesker <valex@mellanox.com>
Mon, 25 Jul 2016 12:42:13 +0000 (15:42 +0300)
committerDavid S. Miller <davem@davemloft.net>
Tue, 26 Jul 2016 01:00:25 +0000 (18:00 -0700)
Verify that the device state is registered before un-registering it.
This check is required to prevent an OOPS on flows that do
re-registration of the device and its previous state was
unregistered.

Fixes: 225c7b1feef1 ("IB/mlx4: Add a driver Mellanox ConnectX InfiniBand adapters")
Signed-off-by: Alex Vesker <valex@mellanox.com>
Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlx4/intf.c

index 7ae1cdad9bf03ec07c0bc055819b515ac9c6f365..0e8b7c44931f907ed881d093077e93b92ae0305d 100644 (file)
@@ -218,6 +218,9 @@ void mlx4_unregister_device(struct mlx4_dev *dev)
        struct mlx4_priv *priv = mlx4_priv(dev);
        struct mlx4_interface *intf;
 
        struct mlx4_priv *priv = mlx4_priv(dev);
        struct mlx4_interface *intf;
 
+       if (!(dev->persist->interface_state & MLX4_INTERFACE_STATE_UP))
+               return;
+
        mlx4_stop_catas_poll(dev);
        mutex_lock(&intf_mutex);
 
        mlx4_stop_catas_poll(dev);
        mutex_lock(&intf_mutex);