* [PATCH net] net/mlx4: fix missing error code in SR-IOV validation
@ 2026-11-30 3:14 mdshahid03
2026-11-30 3:19 ` netdev-bot+sinfo
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: mdshahid03 @ 2026-11-30 3:14 UTC (permalink / raw)
To: tariqt
Cc: andrew+netdev, davem, edumazet, kuba, pabeni, matanb, ogerlitz,
jackm, netdev, linux-rdma, Mohammad Shahid
From: Mohammad Shahid <mdshahid03@gmail.com>
Set err to -EINVAL when SRIOV_VALID_STATE() fails in the
non-SYS_EQS path of mlx4_load_one()
Otherwise, mlx4_load_one() may return success even though
SR-IOV initialization failed.
Fixes: 7ae0e400cd93 ("net/mlx4_core: Flexible (asymmetric) allocation of EQs and MSI-X vectors for PF/VFs")
Signed-off-by: Mohammad Shahid <mdshahid03@gmail.com>
---
drivers/net/ethernet/mellanox/mlx4/main.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c
index 036135df23bf..c3661a346c19 100644
--- a/drivers/net/ethernet/mellanox/mlx4/main.c
+++ b/drivers/net/ethernet/mellanox/mlx4/main.c
@@ -3519,6 +3519,7 @@ static int mlx4_load_one(struct pci_dev *pdev, int pci_dev_data,
dev->flags = dev_flags;
if (!SRIOV_VALID_STATE(dev->flags)) {
mlx4_err(dev, "Invalid SRIOV state\n");
+ err = -EINVAL;
goto err_sriov;
}
err = mlx4_reset(dev);
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH net] net/mlx4: fix missing error code in SR-IOV validation
2026-11-30 3:14 [PATCH net] net/mlx4: fix missing error code in SR-IOV validation mdshahid03
@ 2026-11-30 3:19 ` netdev-bot+sinfo
2026-11-30 3:21 ` sashiko-bot
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: netdev-bot+sinfo @ 2026-11-30 3:19 UTC (permalink / raw)
To: mdshahid03
Cc: tariqt, andrew+netdev, davem, edumazet, kuba, pabeni, matanb,
ogerlitz, jackm, netdev, linux-rdma
Hi!
This is an automated message. This series looks like a fix, but its
commit messages seem to be missing some information:
- How the issue was discovered, e.g. hit in production, hit during
development, syzbot report, manual code inspection, LLM or static
analysis tool scan.
- Whether the issue was actually triggered, or is only theoretical
(e.g. found by LLM and not proven at runtime). If it was triggered
please include the symptoms, like the stack trace or kernel messages.
- What hardware the change was tested on. For driver fixes please
mention the device (and if relevant firmware version) used for
testing, or say that the change was not tested on real hardware.
Please do not repost the series just to address the above. Instead,
reply to this email with the missing information, so that reviewers
can take it into account.
*IMPORTANT*: If you do repost (for other reasons) - please include
the relevant info in the cover letter or commit messages.
--
The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net] net/mlx4: fix missing error code in SR-IOV validation
2026-11-30 3:14 [PATCH net] net/mlx4: fix missing error code in SR-IOV validation mdshahid03
2026-11-30 3:19 ` netdev-bot+sinfo
@ 2026-11-30 3:21 ` sashiko-bot
2026-12-01 3:17 ` netdev-bot+sashiko
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: sashiko-bot @ 2026-11-30 3:21 UTC (permalink / raw)
To: mdshahid03; +Cc: linux-rdma
> From: Mohammad Shahid <mdshahid03@gmail.com>
>
> Set err to -EINVAL when SRIOV_VALID_STATE() fails in the
> non-SYS_EQS path of mlx4_load_one()
>
> Otherwise, mlx4_load_one() may return success even though
> SR-IOV initialization failed.
>
> Fixes: 7ae0e400cd93 ("net/mlx4_core: Flexible (asymmetric) allocation of EQs and MSI-X vectors for PF/VFs")
> Signed-off-by: Mohammad Shahid <mdshahid03@gmail.com>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261130031453.15554-1-mdshahid03@gmail.com?part=1
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net] net/mlx4: fix missing error code in SR-IOV validation
2026-11-30 3:14 [PATCH net] net/mlx4: fix missing error code in SR-IOV validation mdshahid03
2026-11-30 3:19 ` netdev-bot+sinfo
2026-11-30 3:21 ` sashiko-bot
@ 2026-12-01 3:17 ` netdev-bot+sashiko
2026-12-01 17:23 ` Tariq Toukan
2026-12-01 17:38 ` Joe Damato
4 siblings, 0 replies; 6+ messages in thread
From: netdev-bot+sashiko @ 2026-12-01 3:17 UTC (permalink / raw)
To: mdshahid03
Cc: tariqt, andrew+netdev, davem, edumazet, kuba, pabeni, matanb,
ogerlitz, jackm, netdev, linux-rdma
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 1 · Medium: 0 · Low: 1
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 is incomplete.
- [Low] The commit message understates the impact and leaves out when the
bug triggers.
--
net/mlx4: fix missing error code in SR-IOV validation
The patch sets err to -EINVAL when SRIOV_VALID_STATE() fails in the
non-SYS_EQS branch of mlx4_load_one(). Before this, the function jumped
to err_sriov with err still 0 and reported success.
> Otherwise, mlx4_load_one() may return success even though
> SR-IOV initialization failed.
[Severity: Low]
This isn't a bug, but could the commit message describe the impact more
precisely?
When mlx4_load_one() returns 0 here, the err_sriov->err_adev unwind has
already done all of this:
- disabled SR-IOV
- decremented pf_loading
- freed dev_vfs
- released HCA ownership
- freed dev_cap
- cleaned up the adev state
Probe or a reload then reports success for a device that has already
been torn down.
It could also say when SRIOV_VALID_STATE() can fail. As far as I can
tell, the only way is through the failure exits of mlx4_enable_sriov(),
when dev->flags already has MLX4_FLAG_SRIOV set (existing_vfs != 0):
drivers/net/ethernet/mellanox/mlx4/main.c:mlx4_enable_sriov() {
...
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;
}
If the dev_vfs allocation fails, for example, this leaves MLX4_FLAG_SRIOV
set without MLX4_FLAG_MASTER.
The Fixes: target 7ae0e400cd93 goes back to 2014. Should this also carry
Cc: stable@vger.kernel.org? Documentation/process/maintainer-netdev.rst
now asks netdev patches to follow the standard stable rules.
> diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c
> index 036135df23bf1..c3661a346c19e 100644
> --- a/drivers/net/ethernet/mellanox/mlx4/main.c
> +++ b/drivers/net/ethernet/mellanox/mlx4/main.c
> @@ -3519,6 +3519,7 @@ static int mlx4_load_one(struct pci_dev *pdev, int pci_dev_data,
> dev->flags = dev_flags;
> if (!SRIOV_VALID_STATE(dev->flags)) {
> mlx4_err(dev, "Invalid SRIOV state\n");
> + err = -EINVAL;
> goto err_sriov;
> }
> err = mlx4_reset(dev);
[Severity: High]
Are there two more SR-IOV validation sites in mlx4_load_one() with the
same problem? Both jump to err_fw while err is still 0 from the
successful mlx4_QUERY_DEV_CAP() just before:
drivers/net/ethernet/mellanox/mlx4/main.c:mlx4_load_one() {
...
err = mlx4_QUERY_DEV_CAP(dev, dev_cap);
if (err) {
mlx4_err(dev, "QUERY_DEV_CAP command failed, aborting.\n");
goto err_fw;
}
if (mlx4_check_dev_cap(dev, dev_cap, nvfs))
goto err_fw;
...
}
The second one is in the legacy-mode else branch, which runs on the
second pass after goto slave_start.
mlx4_check_dev_cap() returns MLX4_DEV_CAP_CHECK_NUM_VFS_ABOVE_64 (-1)
when 64 or more VFs are requested and the firmware lacks
MLX4_DEV_CAP_FLAG2_80_VFS. Both callers drop that value.
The err_fw->err_mfunc->err_cmd->err_sriov->err_adev unwind closes the
firmware and cleans up the command interface. It then frees dev_vfs,
releases ownership, frees dev_cap and calls mlx4_adev_cleanup(). After
that it returns err, which is still 0:
err_sriov:
...
kfree(priv->dev.dev_vfs);
if (!mlx4_is_slave(dev))
mlx4_free_ownership(dev);
kfree(dev_cap);
err_adev:
mlx4_adev_cleanup(dev);
return err;
__mlx4_init_one() takes the 0 as success, so probe completes and devlink
is registered. mlx4_restart_one_up() also continues into
restore_current_port_types() on the torn-down device.
A later devlink reload then runs
mlx4_devlink_reload_down()->mlx4_restart_one_down()->mlx4_unload_one().
That issues firmware commands through the cleaned-up command interface
and calls mlx4_adev_cleanup() a second time:
drivers/net/ethernet/mellanox/mlx4/intf.c:mlx4_adev_cleanup() {
struct mlx4_priv *priv = mlx4_priv(dev);
kfree(priv->adev);
ida_free(&mlx4_adev_ida, priv->adev_idx);
}
Can this free priv->adev twice and call ida_free() twice on the same id?
If the failure is at the second-pass legacy site, mlx4_unload_one() would
also call kfree(dev->dev_vfs) a second time.
This looks reachable by loading mlx4_core with num_vfs=64 on a ConnectX-2
class device whose firmware lacks MLX4_DEV_CAP_FLAG2_80_VFS.
__mlx4_init_one() accepts that value.
Should both mlx4_check_dev_cap() failure paths also set err, for example
to -EINVAL? Passing the raw -1 through would show up as -EPERM.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261130031453.15554-1-mdshahid03%40gmail.com
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net] net/mlx4: fix missing error code in SR-IOV validation
2026-11-30 3:14 [PATCH net] net/mlx4: fix missing error code in SR-IOV validation mdshahid03
` (2 preceding siblings ...)
2026-12-01 3:17 ` netdev-bot+sashiko
@ 2026-12-01 17:23 ` Tariq Toukan
2026-12-01 17:38 ` Joe Damato
4 siblings, 0 replies; 6+ messages in thread
From: Tariq Toukan @ 2026-12-01 17:23 UTC (permalink / raw)
To: mdshahid03, tariqt
Cc: andrew+netdev, davem, edumazet, kuba, pabeni, matanb, ogerlitz,
jackm, netdev, linux-rdma
On 30/11/2026 5:14, mdshahid03@gmail.com wrote:
> From: Mohammad Shahid <mdshahid03@gmail.com>
>
> Set err to -EINVAL when SRIOV_VALID_STATE() fails in the
> non-SYS_EQS path of mlx4_load_one()
>
> Otherwise, mlx4_load_one() may return success even though
> SR-IOV initialization failed.
>
> Fixes: 7ae0e400cd93 ("net/mlx4_core: Flexible (asymmetric) allocation of EQs and MSI-X vectors for PF/VFs")
> Signed-off-by: Mohammad Shahid <mdshahid03@gmail.com>
> ---
> drivers/net/ethernet/mellanox/mlx4/main.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c
> index 036135df23bf..c3661a346c19 100644
> --- a/drivers/net/ethernet/mellanox/mlx4/main.c
> +++ b/drivers/net/ethernet/mellanox/mlx4/main.c
> @@ -3519,6 +3519,7 @@ static int mlx4_load_one(struct pci_dev *pdev, int pci_dev_data,
> dev->flags = dev_flags;
> if (!SRIOV_VALID_STATE(dev->flags)) {
> mlx4_err(dev, "Invalid SRIOV state\n");
> + err = -EINVAL;
> goto err_sriov;
> }
> err = mlx4_reset(dev);
Thanks for the patch.
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net] net/mlx4: fix missing error code in SR-IOV validation
2026-11-30 3:14 [PATCH net] net/mlx4: fix missing error code in SR-IOV validation mdshahid03
` (3 preceding siblings ...)
2026-12-01 17:23 ` Tariq Toukan
@ 2026-12-01 17:38 ` Joe Damato
4 siblings, 0 replies; 6+ messages in thread
From: Joe Damato @ 2026-12-01 17:38 UTC (permalink / raw)
To: mdshahid03
Cc: tariqt, andrew+netdev, davem, edumazet, kuba, pabeni, matanb,
ogerlitz, jackm, netdev, linux-rdma
On Mon, Nov 30, 2026 at 08:44:53AM +0530, mdshahid03@gmail.com wrote:
> From: Mohammad Shahid <mdshahid03@gmail.com>
>
> Set err to -EINVAL when SRIOV_VALID_STATE() fails in the
> non-SYS_EQS path of mlx4_load_one()
>
> Otherwise, mlx4_load_one() may return success even though
> SR-IOV initialization failed.
>
> Fixes: 7ae0e400cd93 ("net/mlx4_core: Flexible (asymmetric) allocation of EQs and MSI-X vectors for PF/VFs")
> Signed-off-by: Mohammad Shahid <mdshahid03@gmail.com>
> ---
> drivers/net/ethernet/mellanox/mlx4/main.c | 1 +
> 1 file changed, 1 insertion(+)
Reviewed-by: Joe Damato <joe@dama.to>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-12-01 17:38 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-30 3:14 [PATCH net] net/mlx4: fix missing error code in SR-IOV validation mdshahid03
2026-11-30 3:19 ` netdev-bot+sinfo
2026-11-30 3:21 ` sashiko-bot
2026-12-01 3:17 ` netdev-bot+sashiko
2026-12-01 17:23 ` Tariq Toukan
2026-12-01 17:38 ` Joe Damato
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox