Commit d03fc81a authored by Prathamesh Deshpande's avatar Prathamesh Deshpande Committed by Jakub Kicinski
Browse files

net/mlx5: Fix HCA caps leak on notifier init failure



mlx5_mdev_init() allocates HCA caps via mlx5_hca_caps_alloc() before
calling mlx5_notifiers_init(). If notifier initialization fails, the
error path jumps to err_hca_caps and skips mlx5_hca_caps_free(), leaking
allocated caps.

Add a dedicated unwind label for notifier-init failure that frees HCA
caps before continuing the existing cleanup sequence.

Fixes: b6b03097 ("net/mlx5: Initialize events outside devlink lock")
Signed-off-by: default avatarPrathamesh Deshpande <prathameshdeshpande7@gmail.com>
Reviewed-by: default avatarCosmin Ratiu <cratiu@nvidia.com>
Reviewed-by: default avatarTariq Toukan <tariqt@nvidia.com>
Link: https://patch.msgid.link/20260415005022.34764-1-prathameshdeshpande7@gmail.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent cc1ff87b
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -1914,7 +1914,7 @@ int mlx5_mdev_init(struct mlx5_core_dev *dev, int profile_idx)

	err = mlx5_notifiers_init(dev);
	if (err)
		goto err_hca_caps;
		goto err_notifiers_init;

	/* The conjunction of sw_vhca_id with sw_owner_id will be a global
	 * unique id per function which uses mlx5_core.
@@ -1930,6 +1930,8 @@ int mlx5_mdev_init(struct mlx5_core_dev *dev, int profile_idx)

	return 0;

err_notifiers_init:
	mlx5_hca_caps_free(dev);
err_hca_caps:
	mlx5_adev_cleanup(dev);
err_adev_init: