net/ice: fix module EEPROM read

Message ID 20221014053614.9543-1-markus.theil@tu-ilmenau.de (mailing list archive)
State Accepted, archived
Delegated to: Qi Zhang
Headers
Series net/ice: fix module EEPROM read |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/intel-Testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/github-robot: build success github build: passed
ci/iol-aarch64-compile-testing success Testing PASS

Commit Message

Markus Theil Oct. 14, 2022, 5:36 a.m. UTC
From: David MacDougal <david.macdougal@gmail.com>

Fix issue with final word being dropped when retrieving module EEPROM
data for the ice driver.

Take for simplicity the case when `info->offset` is zero and `info->len`
is equal to `SFF_READ_BLOCK_SIZE`. In this case, memcpy would not be
called despite there presumably being room in the buffer
(as we have requested 8 bytes of data and the memcpy would write
precisely 8 bytes). The same edge case will be hit on the final
iteration of the for loop whenever a multiple of 8 bytes is requested,
as the final word will not be written to the data buffer.

Signed-off-by: David MacDougal <david.macdougal@gmail.com>
---
 drivers/net/ice/ice_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--
2.38.0
  

Comments

Qi Zhang Oct. 18, 2022, 4:09 a.m. UTC | #1
> -----Original Message-----
> From: Markus Theil <markus.theil@tu-ilmenau.de>
> Sent: Friday, October 14, 2022 1:36 PM
> To: dev@dpdk.org
> Cc: Yang, Qiming <qiming.yang@intel.com>; Zhang, Qi Z
> <qi.z.zhang@intel.com>; David MacDougal <david.macdougal@gmail.com>
> Subject: [PATCH] net/ice: fix module EEPROM read
> 
> From: David MacDougal <david.macdougal@gmail.com>
> 
> Fix issue with final word being dropped when retrieving module EEPROM
> data for the ice driver.
> 
> Take for simplicity the case when `info->offset` is zero and `info->len` is
> equal to `SFF_READ_BLOCK_SIZE`. In this case, memcpy would not be called
> despite there presumably being room in the buffer (as we have requested 8
> bytes of data and the memcpy would write precisely 8 bytes). The same edge
> case will be hit on the final iteration of the for loop whenever a multiple of 8
> bytes is requested, as the final word will not be written to the data buffer.
> 

Added:
Fixes: 52569256583a ("net/ice: support module EEPROM")
Cc: stable@dpdk.org

> Signed-off-by: David MacDougal <david.macdougal@gmail.com>

Acked-by: Qi Zhang <qi.z.zhang@intel.com>

Applied to dpdk-next-net-intel.

Thanks
Qi
  

Patch

diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c
index 8618a3e6b7..7294f38edc 100644
--- a/drivers/net/ice/ice_ethdev.c
+++ b/drivers/net/ice/ice_ethdev.c
@@ -5206,7 +5206,7 @@  ice_get_module_eeprom(struct rte_eth_dev *dev,
 			}

 			/* Make sure we have enough room for the new block */
-			if ((i + SFF_READ_BLOCK_SIZE) < info->length)
+			if ((i + SFF_READ_BLOCK_SIZE) <= info->length)
 				memcpy(data + i, value, SFF_READ_BLOCK_SIZE);
 		}
 	}