net/mlx5e: Fix error path of updating netdev queues
authorAya Levin <ayal@nvidia.com>
Wed, 21 Apr 2021 11:26:31 +0000 (14:26 +0300)
committerSaeed Mahameed <saeedm@nvidia.com>
Wed, 19 May 2021 06:01:46 +0000 (23:01 -0700)
Avoid division by zero in the error flow. In the driver TC number can be
either 1 or 8. When TC count is set to 1, driver zero netdev->num_tc.
Hence, need to convert it back from 0 to 1 in the error flow.

Fixes: fa3748775b92 ("net/mlx5e: Handle errors from netif_set_real_num_{tx,rx}_queues")
Signed-off-by: Aya Levin <ayal@nvidia.com>
Reviewed-by: Maxim Mikityanskiy <maximmi@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
drivers/net/ethernet/mellanox/mlx5/core/en_main.c

index 89937b05507068ac815d367e92280db135a446f6..d1b9a4040d60de3f1eba6f95cd00cd5470d1ccfa 100644 (file)
@@ -2697,7 +2697,7 @@ static int mlx5e_update_netdev_queues(struct mlx5e_priv *priv)
        int err;
 
        old_num_txqs = netdev->real_num_tx_queues;
-       old_ntc = netdev->num_tc;
+       old_ntc = netdev->num_tc ? : 1;
 
        nch = priv->channels.params.num_channels;
        ntc = priv->channels.params.num_tc;