From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2204A2101A0; Wed, 4 Jun 2025 01:04:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748999054; cv=none; b=MlsnMLq01UaVhCLu7fQGGTXYv98boISo5xVPNhbza0fkOzNz/5vdy2JcQB9aaiPJX92pofUE//uht0VORGqbyFsQwi0ldGrkt/ZlVIISwVDgTAYrV5PvngJOhg308VH8iV9RycuIvF9MElcOmLFpC2fumS2kxhM3z9cKBTy+uIE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748999054; c=relaxed/simple; bh=wCgbi/FTa2Unwe8WYB6oOuLnnI416gMwv7nyWedfbg4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=q//3JJ3RjOBrpth0vw9ZyfrIx3qnxrua1jMkK7pbwV6OCqztvvIZNPqUO5/3yIip7JKdvTsWtSOUMz0S1xs8Nz+gVuwHHGQhv49SbW7R1eRq6RIPSp71TCGaRry08h94iRcA38aOE04htMIul15Boi0lp8EnKckI5IBLe/Fvrzg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jLCSKwv1; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="jLCSKwv1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id ED3F6C4CEF1; Wed, 4 Jun 2025 01:04:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1748999054; bh=wCgbi/FTa2Unwe8WYB6oOuLnnI416gMwv7nyWedfbg4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jLCSKwv1jweQMZGL/9QbEaft2f7xZ7lVPy0f57319zv4f8b18++pN3Ah7ljkiBY+U RJClD4R1RiQoVAoNKsrisIHk8pYBcuGknxySL9P/QANE098ehWErHES+ibv+Z3HJVT I2LRsyxoWE4YLSQi7GqV2585lGm2VrQaGl2dMOlqQo3ncsQnWOGFkRm1mXpy4sl0vA X9XBrL0bN9gHjlWGZqT94SmFviDdlDJkrbCHmmIvf8StfJLcaNSLSm0gVTFoUoDL4l 8tL3TILWuyggxlMHfx208oQvWtfxMlMcY9tipIU7L0jQ7WxQfYSCB854z9axGaGG9x X/ec6IZM8OJSQ== From: Sasha Levin To: patches@lists.linux.dev, stable@vger.kernel.org Cc: Alok Tiwari , Jakub Kicinski , Sasha Levin , ajit.khaparde@broadcom.com, sriharsha.basavapatna@broadcom.com, somnath.kotur@broadcom.com, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 6.1 06/46] emulex/benet: correct command version selection in be_cmd_get_stats() Date: Tue, 3 Jun 2025 21:03:24 -0400 Message-Id: <20250604010404.5109-6-sashal@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250604010404.5109-1-sashal@kernel.org> References: <20250604010404.5109-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.1.140 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Alok Tiwari [ Upstream commit edb888d29748cee674006a52e544925dacc7728e ] Logic here always sets hdr->version to 2 if it is not a BE3 or Lancer chip, even if it is BE2. Use 'else if' to prevent multiple assignments, setting version 0 for BE2, version 1 for BE3 and Lancer, and version 2 for others. Fixes potential incorrect version setting when BE2_chip and BE3_chip/lancer_chip checks could both be true. Signed-off-by: Alok Tiwari Link: https://patch.msgid.link/20250519141731.691136-1-alok.a.tiwari@oracle.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- Based on my analysis, let me provide my determination: **YES** This commit should be backported to stable kernel trees. ## Detailed Analysis: ### 1. **Nature of the Bug:** The commit fixes a logical error in command version selection for the `be_cmd_get_stats()` function in the Emulex be2net driver. The original code had this problematic logic: ```c if (BE2_chip(adapter)) hdr->version = 0; if (BE3_chip(adapter) || lancer_chip(adapter)) // <- Missing "else" hdr->version = 1; else hdr->version = 2; ``` The bug is that the second `if` should be `else if`. Without the `else if`, if a chip satisfies both `BE2_chip(adapter)` AND `(BE3_chip(adapter) || lancer_chip(adapter))` conditions, the version would be incorrectly set multiple times, with the final value being either 1 or 2 depending on subsequent conditions. ### 2. **Impact Assessment:** - **User-facing impact:** This bug could cause incorrect command versions to be sent to the hardware, potentially leading to statistics retrieval failures or unexpected behavior - **Scope:** Affects all users of Emulex be2net network adapters where the chip detection logic could overlap - **Severity:** While not a critical security issue, it affects driver functionality and could lead to network statistics reporting failures ### 3. **Code Change Analysis:** The fix is minimal and surgical: - **Single line change:** Only changes `if` to `else if` on line 1612 - **No functional additions:** Does not introduce new features or change APIs - **Low regression risk:** The change makes the logic more explicit and prevents multiple assignments - **Clear intent:** The fix aligns with the comment stating "version 1 of the cmd is not supported only by BE2" ### 4. **Backport Suitability Criteria:** ✅ **Fixes important bug:** Corrects incorrect hardware command version selection ✅ **Small and contained:** Single line change with no side effects ✅ **Low regression risk:** Makes existing logic more explicit and correct ✅ **No architectural changes:** Pure bug fix without design modifications ✅ **Subsystem confined:** Only affects be2net driver statistics functionality ### 5. **Comparison with Historical Commits:** The provided historical commits were all marked "NO" for backporting because they were: - Version string updates (cosmetic changes) - Code simplifications (non-critical improvements) - Driver version removals (cleanup) In contrast, this commit fixes actual functional logic that could cause incorrect behavior. ### 6. **Stable Tree Compliance:** This commit perfectly fits the stable tree criteria: - Fixes a clear bug in existing code - Has minimal risk of introducing regressions - Affects a specific driver subsystem - Does not change user-visible APIs or behavior (except fixing incorrect behavior) The commit message clearly explains the problem and solution, and the change is straightforward to verify and test. drivers/net/ethernet/emulex/benet/be_cmds.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c b/drivers/net/ethernet/emulex/benet/be_cmds.c index d00f4e29c9d88..17098cd89dfff 100644 --- a/drivers/net/ethernet/emulex/benet/be_cmds.c +++ b/drivers/net/ethernet/emulex/benet/be_cmds.c @@ -1608,7 +1608,7 @@ int be_cmd_get_stats(struct be_adapter *adapter, struct be_dma_mem *nonemb_cmd) /* version 1 of the cmd is not supported only by BE2 */ if (BE2_chip(adapter)) hdr->version = 0; - if (BE3_chip(adapter) || lancer_chip(adapter)) + else if (BE3_chip(adapter) || lancer_chip(adapter)) hdr->version = 1; else hdr->version = 2; -- 2.39.5