net/mlx5e: Don't modify CQ before it was created
authorGal Pressman <galp@mellanox.com>
Tue, 1 Mar 2016 22:13:38 +0000 (00:13 +0200)
committerDavid S. Miller <davem@davemloft.net>
Tue, 1 Mar 2016 22:28:00 +0000 (17:28 -0500)
Calling mlx5e_set_coalesce while the interface is down will result in
modifying CQs that don't exist.

Fixes: f62b8bb8f2d3 ('net/mlx5: Extend mlx5_core to support ConnectX-4
Ethernet functionality')
Signed-off-by: Gal Pressman <galp@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c

index a1b3bb4358b549bc97f442b27430f03ce20cfb10..0959656404b3df249f41dae77901ce3bf7da7577 100644 (file)
@@ -423,11 +423,15 @@ static int mlx5e_set_coalesce(struct net_device *netdev,
        if (!MLX5_CAP_GEN(mdev, cq_moderation))
                return -ENOTSUPP;
 
+       mutex_lock(&priv->state_lock);
        priv->params.tx_cq_moderation_usec = coal->tx_coalesce_usecs;
        priv->params.tx_cq_moderation_pkts = coal->tx_max_coalesced_frames;
        priv->params.rx_cq_moderation_usec = coal->rx_coalesce_usecs;
        priv->params.rx_cq_moderation_pkts = coal->rx_max_coalesced_frames;
 
+       if (!test_bit(MLX5E_STATE_OPENED, &priv->state))
+               goto out;
+
        for (i = 0; i < priv->params.num_channels; ++i) {
                c = priv->channel[i];
 
@@ -443,6 +447,8 @@ static int mlx5e_set_coalesce(struct net_device *netdev,
                                               coal->rx_max_coalesced_frames);
        }
 
+out:
+       mutex_unlock(&priv->state_lock);
        return 0;
 }
 
This page took 0.027587 seconds and 5 git commands to generate.