From: netdev-bot+sashiko@kernel.org
To: 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 v2] net/mlx4: fix error propagation in mlx4_load_one()
Date: Tue, 01 Dec 2026 02:52:42 +0000 [thread overview]
Message-ID: <179609356279.3146.3334572665888004070@kernel.org> (raw)
In-Reply-To: <20261130024959.13483-1-mdshahid03@gmail.com>
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 of the bug it fixes.
--
net/mlx4: fix error propagation in mlx4_load_one()
This commit assigns the return value of mlx4_check_dev_cap() to err at
both call sites in mlx4_load_one(). A failed VF count check is now
propagated instead of returning 0. It also changes mlx4_check_dev_cap()
to return -EINVAL instead of a private enum value.
> If the helper returns an error, execution jumps to err_fw, but err
> may still contain zero from the previous successful operation.
[Severity: Low]
This isn't a bug, but is "may" accurate here? On both patched paths the
preceding mlx4_QUERY_DEV_CAP() call has just succeeded:
err = mlx4_QUERY_DEV_CAP(dev, dev_cap);
if (err) {
mlx4_err(dev, "QUERY_DEV_CAP command failed, aborting.\n");
goto err_fw;
}
So err is always 0 when the old check jumped to err_fw.
Could the changelog also describe the user-visible effect? Suppose the FW
lacks MLX4_DEV_CAP_FLAG2_80_VFS and 64 or more VFs are requested. Then
mlx4_load_one() runs the full err_fw ... err_adev teardown and returns 0.
__mlx4_init_one() then reports a successful probe, and devlink gets
registered for a torn-down device. The reset_flow callers (devlink reload,
catas restart, PCI resume/slot_reset) also report success.
A later devlink reload goes through mlx4_unload_one() with priv->removed
still 0 and repeats the teardown. That includes a second kfree(priv->adev)
in mlx4_adev_cleanup(). mlx4_remove_one() is protected by the
MLX4_INTERFACE_STATE_UP check, but the devlink reload path is not.
This patch has a Fixes: tag. Could the changelog state this consequence?
> diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c
> index 036135df23bf1..96d1e7b58fb77 100644
> --- a/drivers/net/ethernet/mellanox/mlx4/main.c
> +++ b/drivers/net/ethernet/mellanox/mlx4/main.c
[ ... ]
> @@ -3505,7 +3501,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;
>
> if (!(dev_cap->flags2 & MLX4_DEV_CAP_FLAG2_SYS_EQS)) {
[Severity: High]
Is there one more exit in this same block that still returns 0? After
mlx4_check_dev_cap() succeeds here, err is 0. The legacy path then does
this:
drivers/net/ethernet/mellanox/mlx4/main.c:mlx4_load_one() {
...
mlx4_close_fw(dev);
mlx4_cmd_cleanup(dev, MLX4_CMD_CLEANUP_ALL);
dev->flags = dev_flags;
if (!SRIOV_VALID_STATE(dev->flags)) {
mlx4_err(dev, "Invalid SRIOV state\n");
goto err_sriov;
}
...
}
The err_sriov ... err_adev chain tears everything down and ends with
"return err;", which returns 0 here.
Can this state be reached? mlx4_enable_sriov() returns
"dev_flags & ~MLX4_FLAG_MASTER" with MLX4_FLAG_SRIOV still set when the
dev_vfs allocation fails. That can happen in the reset_flow branch
(goto free_mem). It can also happen on a probe where SR-IOV was already
enabled (goto disable_sriov).
The callers then treat the device as loaded:
- __mlx4_init_one() returns 0 and devlink gets registered.
- mlx4_restart_one_up() and mlx4_pci_resume() call
restore_current_port_types() on a device whose FW and command interface
are closed.
A later devlink reload would go through this chain:
mlx4_devlink_reload_down()
mlx4_restart_one_down()
mlx4_unload_one()
mlx4_unload_one() checks only priv->removed, so it repeats the teardown:
- mlx4_close_fw() and mlx4_cmd_cleanup() run a second time.
- mlx4_uar_free() runs on an uninitialized bitmap.
- mlx4_adev_cleanup() runs a second time. It does kfree(priv->adev)
without clearing the pointer, so priv->adev is freed twice.
The SYS_EQS path has the same check, and it sets err first:
if (!SRIOV_VALID_STATE(dev->flags)) {
mlx4_err(dev, "Invalid SRIOV state\n");
err = -EINVAL;
goto err_close;
}
Should the legacy path also set err = -EINVAL before goto err_sriov?
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261130024959.13483-1-mdshahid03%40gmail.com
next prev parent reply other threads:[~2026-12-01 2:52 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-30 2:49 [PATCH net v2] net/mlx4: fix error propagation in mlx4_load_one() mdshahid03
2026-11-30 2:53 ` netdev-bot+sinfo
2026-11-30 2:57 ` sashiko-bot
2026-12-01 2:52 ` netdev-bot+sashiko [this message]
2026-12-01 17:21 ` Tariq Toukan
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=179609356279.3146.3334572665888004070@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--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@vger.kernel.org \
--cc=pabeni@redhat.com \
--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