🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #24045

Re: [PATCH] net/mlx4: fix error propagation in mlx4_load_one()

#24045
From: netdev-bot+sashiko
Date: Sun, 29 Nov 2026 02:38
145 lines
12816 bytes
Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.

Critical: 0 · High: 1 · Medium: 0 · Low: 2

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [High] The fix leaves the same bug in place a few lines further down
  the same block of mlx4_load_one()…
- [Low] The commit fixes a real, user-triggerable bug, but the message
  does not describe its impact and has no Fixes: tag.
- [Low] mlx4_load_one() now passes on the raw return value of
  mlx4_check_dev_cap(), which is the private enum sentinel…

--

net/mlx4: fix error propagation in mlx4_load_one()

This patch assigns the return value of mlx4_check_dev_cap() to err at both
call sites in mlx4_load_one(). Before this, the goto err_fw paths could
return 0 left over from the previous successful command.

> If the helper return an error ,execution jumps to err_fw,but err may
> still contain zero from the previous successful operation.

[Severity: Low]
Could the commit message describe the user-visible impact, and could it
carry a Fixes: tag?

Before this patch, the failure happens when the num_vfs module parameter
requests 64 or more VFs in total on firmware without
MLX4_DEV_CAP_FLAG2_80_VFS (for example CX2). mlx4_check_dev_cap() fails
while err is still 0 from mlx4_QUERY_DEV_CAP().

mlx4_load_one() then runs the full err_fw unwind and returns 0, and
__mlx4_init_one() and mlx4_restart_one_up() treat the device as loaded.

The unchecked call appears to come from:

Fixes: de966c592802 ("net/mlx4_core: Support more than 64 VFs")

> diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c
> index 036135df23bf1..9d89721077c94 100644
> --- a/drivers/net/ethernet/mellanox/mlx4/main.c
> +++ b/drivers/net/ethernet/mellanox/mlx4/main.c
> @@ -3505,7 +3505,8 @@ static int mlx4_load_one(struct pci_dev *pdev, int pci_dev_data,
>  				goto err_fw;
>  			}
>  
> -			if (mlx4_check_dev_cap(dev, dev_cap, nvfs))
> +			err = mlx4_check_dev_cap(dev, dev_cap, nvfs);
> +			if (err)
>  				goto err_fw;

[Severity: Low]
Which value gets propagated here? mlx4_check_dev_cap() returns a private
enum sentinel, not an errno:

enum {
	MLX4_DEV_CAP_CHECK_NUM_VFS_ABOVE_64 = -1,
};

With this change mlx4_load_one() returns -1. __mlx4_init_one() passes that
to the PCI core as the probe result, and mlx4_restart_one_up() returns it
up the devlink reload path. Both will report -EPERM ("Operation not
permitted") for what is really an invalid VF configuration. The same
applies to the second call site in the legacy-mode branch.

Other configuration errors in mlx4_load_one() use -EINVAL, such as the
"Trying to configure VFs on port 2" check.

Would it be better for mlx4_check_dev_cap() to return -EINVAL, or for the
call sites to set err = -EINVAL?

>  
>  			if (!(dev_cap->flags2 & MLX4_DEV_CAP_FLAG2_SYS_EQS)) {

[Severity: High]
Is the same problem still present a few lines further down in this block?
Once mlx4_check_dev_cap() succeeds, err is 0. The invalid SRIOV state
check then jumps to err_sriov without setting err:

drivers/net/ethernet/mellanox/mlx4/main.c:mlx4_load_one() {
    ...
				dev->flags = dev_flags;
				if (!SRIOV_VALID_STATE(dev->flags)) {
					mlx4_err(dev, "Invalid SRIOV state\n");
					goto err_sriov;
				}
    ...
}

This state looks reachable. mlx4_enable_sriov() starts from
dev_flags = dev->flags. If kzalloc_objs() for dev->dev_vfs fails, it
exits through:

disable_sriov:
	atomic_dec(&pf_loading);
free_mem:
	dev->persist->num_vfs = 0;
	kfree(dev->dev_vfs);
	dev->dev_vfs = NULL;
	return dev_flags & ~MLX4_FLAG_MASTER;

Suppose dev->flags already had MLX4_FLAG_SRIOV (existing_vfs != 0, or the
reset_flow path). Then this returns SRIOV set and MASTER cleared, so
SRIOV_VALID_STATE() is false.

The err_sriov unwind then tears everything down, including
mlx4_adev_cleanup(), and mlx4_load_one() returns 0. __mlx4_init_one()
takes its success path:

	err = mlx4_load_one(pdev, pci_dev_data, total_vfs, nvfs, priv, 0);
	if (err)
		goto err_catas;

	return 0;

On the reload path, mlx4_restart_one_up() would also continue into
restore_current_port_types() on the torn-down device.

priv->removed stays 0. Can a later mlx4_unload_one() then run the teardown
a second time, including a second kfree(priv->adev) and ida_free() in
mlx4_adev_cleanup()?

The matching check in the SYS_EQS path already sets err:

		if (!SRIOV_VALID_STATE(dev->flags)) {
			mlx4_err(dev, "Invalid SRIOV state\n");
			err = -EINVAL;
			goto err_close;
		}

Should the non-SYS_EQS check also set err = -EINVAL before the
goto err_sriov?

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261125022913.205366-1-mdshahid03%40gmail.com
Technical Details
Message-ID: <179591990200.3146.7754207940035693581@kernel.org>
Path: mbox-mo1.pugleaf.net!news-can.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-373344-linux-kernel-netdev=dewy.ru
References: <20261125022913.205366-1-mdshahid03@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-can.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-373344-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH] net/mlx4: fix error propagation in mlx4_load_one()
Date: Sun, 29 Nov 2026 02:38:22 +0000
Organization: Usenet Network
Message-ID: <179591990200.3146.7754207940035693581@kernel.org>
References: <20261125022913.205366-1-mdshahid03@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1085229"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:lrdyAlhQhDthxl/BTnzMTp3ND+A= sha256:jnL0TtlehtVKMsqNIsUECD+YYig8SV+dgkXW5wxGLHg=
	sha1:B6qcqdzfgjTHBkVNtuTVKETYcGw= sha256:reA9YgMKE7g/VgZjJFvkH+q770/qrE+/A8n10toYQ4Q=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 1543D125F91; Sun, 29 Nov 2026 05:38:44 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.401
X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id KQchyr3Rz-c5;
	Sun, 29 Nov 2026 05:38:40 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-373344-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id D0E40125F90; Sun, 29 Nov 2026 05:38:28 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id AB2BC24362; Sun, 29 Nov 2026 02:38:24 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1795919904;
	b=am2Kpgn+DIj3ArDESZ0IOW20VmDV3tlxGiucYNLOvQMccJhKe34YfTYse4vvX8nnpVF/
	 pxdbzKn8aXjlKOh+sr5gj8d/zTZAhviCE4VLHVtEOuR2h7GhUiQ61oXQXIiRLso+EOGS5
	 kVefGp/mIBz5Hqr/6G5X60QsFB8n4A9YvqydzS1MUILJiLjRN0K45EXqlnN4hl5kBH4Ig
	 8lhUK/EFUc9g9/vVwJk3HVamSjO8gZ2EC1+/Th42LHI5R4ii2sACh3KoZ987J1NwJsvn+
	 kZa4vlos3FMvGWEWd4wGPH7sk5iTD7IjCyrGvNAJik37gC0zRz40Nb5HLgXmqViSepw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795919904;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=QIfTetId5Raig8Cj0B4D78VNTHdoGkrfeuxiBaNxCL4=;
	b=M0mZbiPqZGa3khYneg+eHZsZGiFGUvOo4EXKNIJb01p60UVdMg8F8iSccs52REhupcav
	 qtyx7+8kWMLglcSLKZ2YYuffoUpI/yXX5xebSGKVmxXo7YD2mdWx9huf9CwYcCCxOUI/R
	 n7YibE5f99vT8ZD8gWbgVq5ICuxEvHlYdNGSzsIB1nC13KhF3pUtRtaC/fcxp15aDzGGK
	 t6LDjJvACGv2JEWUw7or/rzMMB2UCnlnUibrdQsZ3B//4SU+PrHGbr14NQ+NZSfFLALdb
	 51AF8hWiLB6LkOxXdoEevdwoL22sRuGHg6Q25yPRejBz/q+YpHUq73igKLtUAw0+4Dw==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=VnUzrNK6;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 55C83606A326;
	Sun, 29 Nov 2026 02:38:24 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=VnUzrNK6
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1795919903;
	b=02OcrfdQYPLQ3oB+Zs5sOAJDJ5qE3IpdtNSGNRrQBIf4qFaG7hYrkDRcMM7i1mMUnnPb
	 dqVxiv1+CFe9CrZbfjnZ12OsnWtg7zeIXkNKF2xA9Rc8w9dwrsi4h8X7Xl6XCaM2NTvkn
	 KqUKOQ41P7buhx0nOPWvHru1uby/U865tJ+SGpSTKErl0N+E1eIf4h93gpZNPVqMkykDz
	 zXg4pEiat4pg5OLyFl8P1QV7AqYZcmJdxijqP0Sn6OWkHLKWwA3ocTYpUQLaNtKUTI5OM
	 qpCjvFcANubppICBxIOKoTSo10e3684oHOAuamOSkS8alV2bsQsgJzUi6StJz0VfJPA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795919903;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=QIfTetId5Raig8Cj0B4D78VNTHdoGkrfeuxiBaNxCL4=;
	b=t/P0/hu0CZ5S7qT9uxBkT4m/+0CCQva6tU6Ou8gaHFtJm2e51qLakJSf01QphumJ/EYg
	 upMBzMr8lirZ6rnTWNUMw8wyniu/HQHlgJ4uSqIroBRgV2l8+ywO+/TdbcBP1wFDBPmU7
	 RCZmdpG1HPtNPEaT0vwOP4iQV+WiPMP8Vp3Qq0LwQhK8p/Gf5RQ78RxJy6bCYBUsz9XT+
	 fsgicRX0bOKcNFqLX7YwcdPM33HEg30vPbfT3nHUNKgrgNRGZayyDD0emY0W7Gf5wVBkh
	 bJAINQFzpmX4QNtPGXltUXn3QCqyugUpY7J4opJ7kQtG9vP3JlzwPzQYrytS2gityXw==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=VnUzrNK6;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 72878606A31C;
	Sun, 29 Nov 2026 02:38:23 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 79BDB1F000C1;
	Sun, 29 Nov 2026 02:38:22 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795919903;
	bh=QIfTetId5Raig8Cj0B4D78VNTHdoGkrfeuxiBaNxCL4=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=VnUzrNK6tddyIlGOCvYa0uBe4Scyw17ja7AUgxhGFG7LW31//1EflrG+0dXHRNsOg
	 +8T6FlBGO7Db32WaqYwitLMRN9BTYQPCSr92KGB9VvkrbazbF4vLMp5ZupZk3z5cRG
	 gTRanHpm4NJK5885gc0BXM50Vcd5gnR0X54oE5q4JIRHUt5Q5FyumXuVLfgFdNaat3
	 ONJWSXkStF41Lcoshcx8a6BJYd0GWS9+0Iw9Mx8rfYSZhyCZxpHfLC+PZKSuUAouW4
	 +v4RLS4OkBRrAZHQxOSHkjWcNIyf2+DELkmuqW71m7zAZ/tMJ2CVdHckcR3tWA2LLK
	 7ZZGd1aIEcuog==
X-Cc: tariqt@nvidia.com, andrew+netdev@lunn.ch, davem@davemloft.net,
 edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com,
 netdev@vger.kernel.org, linux-rdma@vger.kernel.org
X-In-Reply-To: <20261125022913.205366-1-mdshahid03@gmail.com>
X-sashiko-severity: High
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list