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=1796093564; b=ATV5QAiuzCqJOZNREsee/+awh27YhGgaJ2kh8mncpfZpBtDepSZrB3V8h07Eu6Vn+9T3 fttGf6GyReeUT7iOqI1lFY/AAUxmuyIy30yHIXUdQqC9NpUGelDRQ6GwVp1BttNR80wx7 17DVUZ2d1iDvqZeSkwMIgOKXBu0z+zgz9e0LmkGZTgeL4usoPJtsSy+cmrKRlmxORbKEI 8ImM+o0PgFfRaVWkJp0UR++xOKAYlIBgpGyVPev/2jmHSeyn8Wd8H5O3+Ir4MYu1jgjTX /ziTyq3Du0kIgd6JwshsWpiVFHPrBWHmftFUbBJNSIz6PBcllknmg3ctopsEWh+HqEw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796093564; 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=b604eSCxKyZo+/uXsyzYjI1+g5W1EePHR2yJRUx8Njc=; b=iw/2/pYqhoDc86rQqvd9jTv7+LKJ4yCEClfdndQkeeRhtpH/kUqOkmmOKK7nvlY2WeX7 3SzRrNd60s0cxSbBLMgTtPhweCpCOZJ2nK7jmx4L+PBvJr6n4ABLZCSXqhdKGQXRtUxfp pFsbQp+laKYgdFaJN70g9CT457J/7G6MMDa8dWJ7to02DoEVq0rKw5b2dcnINzhBJ8Fpl yoW6gV4/py44ihPL3UH5GHQzMr7Q8Psj/ucbNQ6cwrAYUZiRviMr74HUVw01ve08jvNNG Of812YD5/HMVmxnjHfWxmW/a5kAs0zKxI7s2A/WcPQiW0GNryWFQvvWWukt8KNTenTw== 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="hKqbSeh/"; 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 091D7606A320; Tue, 1 Dec 2026 02:52:44 +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=hKqbSeh/ Received: by smtp.kernel.org (Postfix) with ESMTPSA id 45C171F00899; Tue, 1 Dec 2026 02:52:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796093563; bh=b604eSCxKyZo+/uXsyzYjI1+g5W1EePHR2yJRUx8Njc=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=hKqbSeh/8p1DFXcRmnIZv5Y2C8K9OxV8G0ubRhkPSqK/kd9JEPF0vd5XyFuElqOf1 7+/xqz0F5kpx+8IkeU8DN3uhVUCP04tKQ70AlptAXuxXEgVQaanGNOA0UkBSEUBaQX 2w2J6dtBZ8kZMfYI2MRRMDnvCKwetLc/96seFq3zNbSsPr1CZISBw5wBpuPaNDGGgO A1vDHXkgUyZM6syrER7VVKtapprlgOasIY3dKraSMP93oDd6qGF/UHw/5nX2ti5z34 wYj1N7Lp58o8ALGuLGhdtDFZ+mYEew6F6vdL0bTyQN+IlJEvR/yT3nmk8wrQcLPMgY zPsdMcgv/ms+Q== Subject: Re: [PATCH net v2] 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: Tue, 01 Dec 2026 02:52:42 +0000 Message-ID: <179609356279.3146.3334572665888004070@kernel.org> In-Reply-To: <20261130024959.13483-1-mdshahid03@gmail.com> References: <20261130024959.13483-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 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