Blame SOURCES/0001-e100-fix-length-calculation-in-e100_get_regs_len.patch

Kmods SIG 25e717
From 4329c8dc110b25d5f04ed20c6821bb60deff279f Mon Sep 17 00:00:00 2001
Kmods SIG 25e717
From: Jacob Keller <jacob.e.keller@intel.com>
Kmods SIG 25e717
Date: Wed, 8 Sep 2021 10:52:36 -0700
Kmods SIG 25e717
Subject: [Backport 4329c8dc110b] e100: fix length calculation in
Kmods SIG 25e717
 e100_get_regs_len
Kmods SIG 25e717
Kmods SIG 25e717
commit abf9b902059f ("e100: cleanup unneeded math") tried to simplify
Kmods SIG 25e717
e100_get_regs_len and remove a double 'divide and then multiply'
Kmods SIG 25e717
calculation that the e100_reg_regs_len function did.
Kmods SIG 25e717
Kmods SIG 25e717
This change broke the size calculation entirely as it failed to account
Kmods SIG 25e717
for the fact that the numbered registers are actually 4 bytes wide and
Kmods SIG 25e717
not 1 byte. This resulted in a significant under allocation of the
Kmods SIG 25e717
register buffer used by e100_get_regs.
Kmods SIG 25e717
Kmods SIG 25e717
Fix this by properly multiplying the register count by u32 first before
Kmods SIG 25e717
adding the size of the dump buffer.
Kmods SIG 25e717
Kmods SIG 25e717
Fixes: abf9b902059f ("e100: cleanup unneeded math")
Kmods SIG 25e717
Reported-by: Felicitas Hetzelt <felicitashetzelt@gmail.com>
Kmods SIG 25e717
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Kmods SIG 25e717
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
Kmods SIG 25e717
---
Kmods SIG 25e717
 src/e100.c | 6 +++++-
Kmods SIG 25e717
 1 file changed, 5 insertions(+), 1 deletion(-)
Kmods SIG 25e717
Kmods SIG 25e717
diff --git a/src/e100.c b/src/e100.c
Kmods SIG 25e717
index 373eb027b925207fdc70b47e413c4055559a2e2d..588a59546d1237e7afb1e6b9bfcce37ecdf03a1c 100644
Kmods SIG 25e717
--- a/src/e100.c
Kmods SIG 25e717
+++ b/src/e100.c
Kmods SIG 25e717
@@ -2441,7 +2441,11 @@ static void e100_get_drvinfo(struct net_device *netdev,
Kmods SIG 25e717
 static int e100_get_regs_len(struct net_device *netdev)
Kmods SIG 25e717
 {
Kmods SIG 25e717
 	struct nic *nic = netdev_priv(netdev);
Kmods SIG 25e717
-	return 1 + E100_PHY_REGS + sizeof(nic->mem->dump_buf);
Kmods SIG 25e717
+
Kmods SIG 25e717
+	/* We know the number of registers, and the size of the dump buffer.
Kmods SIG 25e717
+	 * Calculate the total size in bytes.
Kmods SIG 25e717
+	 */
Kmods SIG 25e717
+	return (1 + E100_PHY_REGS) * sizeof(u32) + sizeof(nic->mem->dump_buf);
Kmods SIG 25e717
 }
Kmods SIG 25e717
 
Kmods SIG 25e717
 static void e100_get_regs(struct net_device *netdev,
Kmods SIG 25e717
-- 
Kmods SIG 25e717
2.31.1
Kmods SIG 25e717