From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EC4C43A7850; Wed, 20 May 2026 17:01:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779296465; cv=none; b=BbFdHZRo4EUm7im7AvFVJqavUVv8np6Vmj2Ym+iTaIQscHfaQTyWUYIJtZ8g0dJ1rb3TNvjwSiDLycRBj9tY8kc3a1dJ0NT8IHag3crMmaMUuwJ52oGThqK6pdLp4RanV0aIutFMSGVyoR7Q5iPUjAUusCXrcw18Y0GR5wogr+s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779296465; c=relaxed/simple; bh=pfIpexa8RoFO9inU/acA/s5qnDaKlktKZhKkPLQEy7E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=E1+YsfqEn4Mb5MYWAguuVZ2fL/PvK00A/17PT7dwW+/pzLN2vo0tKNiFCvc+/86jCV3JHizfL2Se01CmcM5HVxlpFz40sbyy8FLDlHGWD3tS79tiwaiiDLgPwZbl6F2HWMpLOODTyXVpX1A3vKLO2I86jP2WdnMKDYZ/jIDl1B8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=XMRtGj7p; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="XMRtGj7p" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5E7EF1F000E9; Wed, 20 May 2026 17:01:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1779296463; bh=mexmh4jMGnGVHVz+kPu9AHgpNCIWpupx4dtWgw2wfCg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=XMRtGj7pLJwYudA1JfzqJnaV++z5SY9U3UK+SIZlZgBUHbHyEwZmT4EuCA9v9Lg4b EVi3YFpSGRuwzpYu92aOH8MivFYAmgYt+97cdVGPDnEdoWzIo5eDHUs2Qq91OcpJeW Z4zgU/DGWJTpxhgphEdBbncSTPkIC/+0KuNwtuL4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Prathamesh Deshpande , Cosmin Ratiu , Tariq Toukan , Jakub Kicinski , Sasha Levin Subject: [PATCH 7.0 0808/1146] net/mlx5: Fix HCA caps leak on notifier init failure Date: Wed, 20 May 2026 18:17:38 +0200 Message-ID: <20260520162206.510385722@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260520162148.390695140@linuxfoundation.org> References: <20260520162148.390695140@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.0-stable review patch. If anyone has any objections, please let me know. ------------------ From: Prathamesh Deshpande [ Upstream commit d03fc81a57956248383efec99967d0ae627390a8 ] 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: b6b03097f982 ("net/mlx5: Initialize events outside devlink lock") Signed-off-by: Prathamesh Deshpande Reviewed-by: Cosmin Ratiu Reviewed-by: Tariq Toukan Link: https://patch.msgid.link/20260415005022.34764-1-prathameshdeshpande7@gmail.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- drivers/net/ethernet/mellanox/mlx5/core/main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c b/drivers/net/ethernet/mellanox/mlx5/core/main.c index 3f73d9b1115dd..fab80c79ff071 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c @@ -1907,7 +1907,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. @@ -1923,6 +1923,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: -- 2.53.0