net/ice: fix EEPROM range check

Message ID 20190505054821.133639-1-xiao.w.wang@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Qi Zhang
Headers
Series net/ice: fix EEPROM range check |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/mellanox-Performance-Testing fail Performance Testing issues
ci/intel-Performance-Testing success Performance Testing PASS

Commit Message

Xiao Wang May 5, 2019, 5:48 a.m. UTC
  The last word should not cross shadow RAM boundary.

Fixes: 68a1ab82ad74 ("net/ice: speed up to retrieve EEPROM")
Cc: stable@dpdk.org

Signed-off-by: Xiao Wang <xiao.w.wang@intel.com>
---
 drivers/net/ice/ice_ethdev.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Comments

Qi Zhang May 6, 2019, 12:37 a.m. UTC | #1
> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Xiao Wang
> Sent: Sunday, May 5, 2019 1:48 PM
> To: Lu, Wenzhuo <wenzhuo.lu@intel.com>
> Cc: dev@dpdk.org; Yang, Qiming <qiming.yang@intel.com>; Rong, Leyi
> <leyi.rong@intel.com>; Wang, Xiao W <xiao.w.wang@intel.com>;
> stable@dpdk.org
> Subject: [dpdk-dev] [PATCH] net/ice: fix EEPROM range check
> 
> The last word should not cross shadow RAM boundary.
> 
> Fixes: 68a1ab82ad74 ("net/ice: speed up to retrieve EEPROM")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Xiao Wang <xiao.w.wang@intel.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 706632424..3d2f35bb0 100644
--- a/drivers/net/ice/ice_ethdev.c
+++ b/drivers/net/ice/ice_ethdev.c
@@ -3002,8 +3002,8 @@  ice_get_eeprom(struct rte_eth_dev *dev,
 	last_word = (eeprom->offset + eeprom->length - 1) >> 1;
 	nwords = last_word - first_word + 1;
 
-	if (first_word > hw->nvm.sr_words ||
-	    last_word > hw->nvm.sr_words) {
+	if (first_word >= hw->nvm.sr_words ||
+	    last_word >= hw->nvm.sr_words) {
 		PMD_DRV_LOG(ERR, "Requested EEPROM bytes out of range.");
 		return -EINVAL;
 	}