From patchwork Fri Oct 14 05:36:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Theil X-Patchwork-Id: 118177 X-Patchwork-Delegate: qi.z.zhang@intel.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org 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 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 Acked-by: Qi Zhang --- drivers/net/ice/ice_ethdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.38.0 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); } }