Skip to content

Commit

Permalink
net/mlx5: Don't skip subfunction cleanup in case of error in module init
Browse files Browse the repository at this point in the history
[ Upstream commit c633e79 ]

Clean SF resources if mlx5 eth failed to initialize.

Fixes: 1958fc2 ("net/mlx5: SF, Add auxiliary device driver")
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
Reviewed-by: Parav Pandit <parav@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
rleon authored and gregkh committed Aug 18, 2021
1 parent f49d457 commit df712c5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
12 changes: 4 additions & 8 deletions drivers/net/ethernet/mellanox/mlx5/core/main.c
Expand Up @@ -1781,16 +1781,14 @@ static int __init init(void)
if (err)
goto err_sf;

#ifdef CONFIG_MLX5_CORE_EN
err = mlx5e_init();
if (err) {
pci_unregister_driver(&mlx5_core_driver);
goto err_debug;
}
#endif
if (err)
goto err_en;

return 0;

err_en:
mlx5_sf_driver_unregister();
err_sf:
pci_unregister_driver(&mlx5_core_driver);
err_debug:
Expand All @@ -1800,9 +1798,7 @@ static int __init init(void)

static void __exit cleanup(void)
{
#ifdef CONFIG_MLX5_CORE_EN
mlx5e_cleanup();
#endif
mlx5_sf_driver_unregister();
pci_unregister_driver(&mlx5_core_driver);
mlx5_unregister_debugfs();
Expand Down
5 changes: 5 additions & 0 deletions drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h
Expand Up @@ -223,8 +223,13 @@ int mlx5_firmware_flash(struct mlx5_core_dev *dev, const struct firmware *fw,
int mlx5_fw_version_query(struct mlx5_core_dev *dev,
u32 *running_ver, u32 *stored_ver);

#ifdef CONFIG_MLX5_CORE_EN
int mlx5e_init(void);
void mlx5e_cleanup(void);
#else
static inline int mlx5e_init(void){ return 0; }
static inline void mlx5e_cleanup(void){}
#endif

static inline bool mlx5_sriov_is_enabled(struct mlx5_core_dev *dev)
{
Expand Down

0 comments on commit df712c5

Please sign in to comment.