Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net/mlx5e: Allocate flow steering storage during uplink initialization

IPsec code relies on valid priv->fs pointer that is the case in NIC
flow, but not correct in uplink. Before commit that mentioned in the
Fixes line, that pointer was valid in all flows as it was allocated
together with priv struct.

In addition, the cleanup representors routine called to that
not-initialized priv->fs pointer and its internals which caused NULL
deference.

So, move FS allocation to be as early as possible.

Fixes: af8bbf730068 ("net/mlx5e: Convert mlx5e_flow_steering member of mlx5e_priv to pointer")
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
Link: https://lore.kernel.org/r/ae46fa5bed3c67f937bfdfc0370101278f5422f1.1660639564.git.leonro@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Leon Romanovsky and committed by
Jakub Kicinski
d515f38c 5b6a0729

+17 -8
+17 -8
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
··· 696 696 { 697 697 struct mlx5e_priv *priv = netdev_priv(netdev); 698 698 699 + priv->fs = mlx5e_fs_init(priv->profile, mdev, 700 + !test_bit(MLX5E_STATE_DESTROYING, &priv->state)); 701 + if (!priv->fs) { 702 + netdev_err(priv->netdev, "FS allocation failed\n"); 703 + return -ENOMEM; 704 + } 705 + 699 706 mlx5e_build_rep_params(netdev); 700 707 mlx5e_timestamp_init(priv); 701 708 ··· 715 708 struct mlx5e_priv *priv = netdev_priv(netdev); 716 709 int err; 717 710 711 + priv->fs = mlx5e_fs_init(priv->profile, mdev, 712 + !test_bit(MLX5E_STATE_DESTROYING, &priv->state)); 713 + if (!priv->fs) { 714 + netdev_err(priv->netdev, "FS allocation failed\n"); 715 + return -ENOMEM; 716 + } 717 + 718 718 err = mlx5e_ipsec_init(priv); 719 719 if (err) 720 720 mlx5_core_err(mdev, "Uplink rep IPsec initialization failed, %d\n", err); 721 721 722 722 mlx5e_vxlan_set_netdev_info(priv); 723 - return mlx5e_init_rep(mdev, netdev); 723 + mlx5e_build_rep_params(netdev); 724 + mlx5e_timestamp_init(priv); 725 + return 0; 724 726 } 725 727 726 728 static void mlx5e_cleanup_rep(struct mlx5e_priv *priv) ··· 851 835 { 852 836 struct mlx5_core_dev *mdev = priv->mdev; 853 837 int err; 854 - 855 - priv->fs = mlx5e_fs_init(priv->profile, mdev, 856 - !test_bit(MLX5E_STATE_DESTROYING, &priv->state)); 857 - if (!priv->fs) { 858 - netdev_err(priv->netdev, "FS allocation failed\n"); 859 - return -ENOMEM; 860 - } 861 838 862 839 priv->rx_res = mlx5e_rx_res_alloc(); 863 840 if (!priv->rx_res) {