From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A856EA00C2; Fri, 14 Oct 2022 07:36:33 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5CE164014F; Fri, 14 Oct 2022 07:36:33 +0200 (CEST) Received: from smail.rz.tu-ilmenau.de (smail.rz.tu-ilmenau.de [141.24.186.67]) by mails.dpdk.org (Postfix) with ESMTP id BAB21400D4 for ; Fri, 14 Oct 2022 07:36:31 +0200 (CEST) Received: from isengard.fritz.box (p54aef542.dip0.t-ipconnect.de [84.174.245.66]) by smail.rz.tu-ilmenau.de (Postfix) with ESMTPA id 580A8580098; Fri, 14 Oct 2022 07:36:31 +0200 (CEST) From: Markus Theil To: dev@dpdk.org Cc: Qiming Yang , Qi Zhang , David MacDougal Subject: [PATCH] net/ice: fix module EEPROM read Date: Fri, 14 Oct 2022 07:36:15 +0200 Message-Id: <20221014053614.9543-1-markus.theil@tu-ilmenau.de> X-Mailer: git-send-email 2.38.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: David MacDougal 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 --- drivers/net/ice/ice_ethdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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); } } -- 2.38.0