From: Tariq Toukan <tariqt@nvidia.com>
To: netdev-bot+sashiko@kernel.org, mdshahid03@gmail.com
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
Subject: Re: [PATCH] net/mlx4: fix error propagation in mlx4_load_one()
Date: Sun, 29 Nov 2026 11:16:14 +0200 [thread overview]
Message-ID: <6a2e2a9d-090e-4bd4-ad13-be5dbb595cca@nvidia.com> (raw)
In-Reply-To: <179591990200.3146.7754207940035693581@kernel.org>
On 29/11/2026 4:38, netdev-bot+sashiko@kernel.org wrote:
> 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")
>
Please address.
>> 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?
>
Please address.
>>
>> 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?
>
> [ ... ]
>
It can be a separate patch, as it has a different Fixes tag:
Fixes: 7ae0e400cd93 ("net/mlx4_core: Flexible (asymmetric) allocation of
EQs and MSI-X vectors for PF/VFs")
Please target net branch in your V2.
prev parent reply other threads:[~2026-11-29 9:16 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 2:29 [PATCH] net/mlx4: fix error propagation in mlx4_load_one() mdshahid03
2026-11-25 2:33 ` netdev-bot+sinfo
2026-11-25 18:12 ` Joe Damato
2026-11-29 2:38 ` netdev-bot+sashiko
2026-11-29 9:16 ` Tariq Toukan [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=6a2e2a9d-090e-4bd4-ad13-be5dbb595cca@nvidia.com \
--to=tariqt@nvidia.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=mdshahid03@gmail.com \
--cc=netdev-bot+sashiko@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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