From: Shay Drori <shayd@nvidia.com>
To: "Ваторопин Андрей" <a.vatoropin@crpt.ru>,
"Saeed Mahameed" <saeedm@nvidia.com>
Cc: Leon Romanovsky <leon@kernel.org>,
Tariq Toukan <tariqt@nvidia.com>,
"Mark Bloch" <mbloch@nvidia.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
"Jakub Kicinski" <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.com>, Gal Pressman <gal@nvidia.com>,
Patrisious Haddad <phaddad@nvidia.com>,
Gerd Bayer <gbayer@linux.ibm.com>,
"Mark Zhang (Networking SW)" <markzhang@nvidia.com>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"linux-rdma@vger.kernel.org" <linux-rdma@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"lvc-project@linuxtesting.org" <lvc-project@linuxtesting.org>,
"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: Re: [PATCH net] net/mlx5: return error in case of lag device allocation failure
Date: Mon, 9 Feb 2026 08:36:14 +0200 [thread overview]
Message-ID: <edc2fd39-c8b7-40eb-9148-85e97eb32af4@nvidia.com> (raw)
In-Reply-To: <20260205114206.1763509-1-a.vatoropin@crpt.ru>
On 05/02/2026 13:42, Ваторопин Андрей wrote:
> External email: Use caution opening links or attachments
>
>
> From: Andrey Vatoropin <a.vatoropin@crpt.ru>
>
> The function __mlx5_lag_dev_add_mdev() attempts to allocate memory for the
> pointer ldev by calling the function mlx5_lag_dev_alloc(). If the memory
> allocation fails, mlx5_lag_dev_alloc() returns NULL and the
> __mlx5_lag_dev_add_mdev() returns 0. Later in the debugfs handlers there is
> an attempt to dereference the ldev pointer.
>
> Change the return value to "-ENOMEM" to avoid NULL pointer using. When
> "-ENOMEM" is returned __mlx5_lag_dev_add_mdev() will attempt to
> reallocate memory for ldev after a sleep interval.
first, mlx5 treat LAG failures as non-critical. e.g.: if LAG is failing
or isn't supported, the driver won't stop loading.
Second, we have a fix in the pipeline that fixes this by adding
a check in the debugfs creation function, can you wait for it?
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>
> Fixes: cac1eb2cf2e3 ("net/mlx5: Lag, properly lock eswitch if needed")> Cc: stable@vger.kernel.org
> Signed-off-by: Andrey Vatoropin <a.vatoropin@crpt.ru>
> ---
> drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c b/drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c
> index a459a30f36ca..6e914472a2d7 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c
> @@ -1392,7 +1392,7 @@ static int __mlx5_lag_dev_add_mdev(struct mlx5_core_dev *dev)
> ldev = mlx5_lag_dev_alloc(dev);
> if (!ldev) {
> mlx5_core_err(dev, "Failed to alloc lag dev\n");
> - return 0;
> + return -ENOMEM;
Also, This change could lead to endless loop in mlx5_lag_add_mdev().
> }
> mlx5_ldev_add_mdev(ldev, dev);
> return 0;
> --
> 2.43.0
Thanks
Shay
prev parent reply other threads:[~2026-02-09 6:36 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-05 11:42 [PATCH net] net/mlx5: return error in case of lag device allocation failure Ваторопин Андрей
2026-02-09 6:36 ` Shay Drori [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=edc2fd39-c8b7-40eb-9148-85e97eb32af4@nvidia.com \
--to=shayd@nvidia.com \
--cc=a.vatoropin@crpt.ru \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=gal@nvidia.com \
--cc=gbayer@linux.ibm.com \
--cc=kuba@kernel.org \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=lvc-project@linuxtesting.org \
--cc=markzhang@nvidia.com \
--cc=mbloch@nvidia.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=phaddad@nvidia.com \
--cc=saeedm@nvidia.com \
--cc=stable@vger.kernel.org \
--cc=tariqt@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox