net/mlx5e: reset XPS on error flow if netdev isn't registered yet
authorSaeed Mahameed <saeedm@nvidia.com>
Thu, 25 Feb 2021 19:20:00 +0000 (11:20 -0800)
committerSaeed Mahameed <saeedm@nvidia.com>
Wed, 19 May 2021 06:01:38 +0000 (23:01 -0700)
commit77ecd10d0a8aaa6e4871d8c63626e4c9fc5e47db
tree60426546b4d9b07f859b17048364af68ad884edc
parenteb96cc15926f4ddde3a28c42feeffdf002451c24
net/mlx5e: reset XPS on error flow if netdev isn't registered yet

mlx5e_attach_netdev can be called prior to registering the netdevice:
Example stack:

ipoib_new_child_link ->
ipoib_intf_init->
rdma_init_netdev->
mlx5_rdma_setup_rn->

mlx5e_attach_netdev->
mlx5e_num_channels_changed ->
mlx5e_set_default_xps_cpumasks ->
netif_set_xps_queue ->
__netif_set_xps_queue -> kmalloc

If any later stage fails at any point after mlx5e_num_channels_changed()
returns, XPS allocated maps will never be freed as they
are only freed during netdev unregistration, which will never happen for
yet to be registered netdevs.

Fixes: 3909a12e7913 ("net/mlx5e: Fix configuration of XPS cpumasks and netdev queues in corner cases")
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
Signed-off-by: Aya Levin <ayal@nvidia.com>
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
drivers/net/ethernet/mellanox/mlx5/core/en_main.c