net/mlx5e: Fix NULL pointer derefernce in set channels error flow [Linux 5.0]

This Linux kernel change "net/mlx5e: Fix NULL pointer derefernce in set channels error flow" is included in the Linux 5.0 release. This change is authored by Maria Pasechnik <mariap [at]> on Sun Feb 3 17:55:09 2019 +0200. The commit for this change in Linux stable tree is fb35c53 (patch).

net/mlx5e: Fix NULL pointer derefernce in set channels error flow

New channels are applied to the priv channels only after they
are successfully opened. Then, the indirection table should be built
according to the new number of channels.
Currently, such build is preformed independently of whether the
channels opening is successful, and is not reverted on failure.

The bug is caused due to removal of rss params from channels struct
and moving it to priv struct. That change cause to independency between
channels and rss params.
This causes a crash on a later point, when accessing rqn of a non
existing channel.

This patch fixes it by moving the indirection table build right before
switching the priv channels to new channels struct, after the new set of
channels was successfully opened.

Fixes: bbeb53b8b2c9 ("net/mlx5e: Move RSS params to a dedicated struct")
Signed-off-by: Maria Pasechnik <[email protected]>
Reviewed-by: Tariq Toukan <[email protected]>
Signed-off-by: Saeed Mahameed <[email protected]>

There are 7 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
index 3bbccea..47233b9 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
@@ -354,9 +354,6 @@ int mlx5e_ethtool_set_channels(struct mlx5e_priv *priv,

    new_channels.params = priv->channels.params;
    new_channels.params.num_channels = count;
-   if (!netif_is_rxfh_configured(priv->netdev))
-       mlx5e_build_default_indir_rqt(priv->rss_params.indirection_rqt,
-                         MLX5E_INDIR_RQT_SIZE, count);

    if (!test_bit(MLX5E_STATE_OPENED, &priv->state)) {
        priv->channels.params = new_channels.params;
@@ -372,6 +369,10 @@ int mlx5e_ethtool_set_channels(struct mlx5e_priv *priv,
    if (arfs_enabled)

+   if (!netif_is_rxfh_configured(priv->netdev))
+       mlx5e_build_default_indir_rqt(priv->rss_params.indirection_rqt,
+                         MLX5E_INDIR_RQT_SIZE, count);
    /* Switch to new channels, set new parameters and close old ones */
    mlx5e_switch_priv_channels(priv, &new_channels, NULL);

Leave a Reply

Your email address will not be published. Required fields are marked *