From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 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== 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== 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 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) 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 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 79BDB1F000C1; Sun, 29 Nov 2026 02:38:22 +0000 (UTC) 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== Subject: Re: [PATCH] net/mlx4: fix error propagation in mlx4_load_one() 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 Date: Sun, 29 Nov 2026 02:38:22 +0000 Message-ID: <179591990200.3146.7754207940035693581@kernel.org> In-Reply-To: <20261125022913.205366-1-mdshahid03@gmail.com> References: <20261125022913.205366-1-mdshahid03@gmail.com> X-sashiko-severity: High Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 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