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