All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marcel Telka <marcel@telka.sk>
To: dev@dpdk.org
Cc: stable@dpdk.org
Subject: [PATCH v2] net/ice: fix trailing bytes drop in get_module_eeprom()
Date: Fri, 13 Nov 2026 11:47:58 +0100	[thread overview]
Message-ID: <avbq3hRC0CYC4f_q@telcontar> (raw)
In-Reply-To: <avXWJrAYifpAF9nJ@telcontar>

When info->length is not an exact multiple of SFF_READ_BLOCK_SIZE (8),
the final loop iteration reads the correct 8 bytes from the module into
value[], but the guard evaluates false, so the memcpy is skipped
entirely. Since the destination buffer is memset to 0 at function entry,
the trailing length % 8 bytes are silently returned as zero instead of
the real EEPROM content, with no error indication to the caller.

Bugzilla ID: 2091
Fixes: 5256925658 (net/ice: support module EEPROM)
Cc: stable@dpdk.org

Signed-off-by: Marcel Telka <marcel@telka.sk>
---
 drivers/net/intel/ice/ice_ethdev.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/net/intel/ice/ice_ethdev.c b/drivers/net/intel/ice/ice_ethdev.c
index 457c955b2e..3de9840e7c 100644
--- a/drivers/net/intel/ice/ice_ethdev.c
+++ b/drivers/net/intel/ice/ice_ethdev.c
@@ -6750,6 +6750,8 @@ ice_get_module_eeprom(struct rte_eth_dev *dev,
 		 * SFP modules only ever use page 0.
 		 */
 		if (page == 0 || !(data[0x2] & 0x4)) {
+			uint32_t copy_len;
+
 			/* If i2c bus is busy due to slow page change or
 			 * link management access, call can fail.
 			 * This is normal. So we retry this a few times.
@@ -6777,9 +6779,12 @@ ice_get_module_eeprom(struct rte_eth_dev *dev,
 				break;
 			}
 
-			/* Make sure we have enough room for the new block */
-			if ((i + SFF_READ_BLOCK_SIZE) <= info->length)
-				memcpy(data + i, value, SFF_READ_BLOCK_SIZE);
+			/* Clamp the copy to the bytes actually requested: the final
+			 * block is shorter than SFF_READ_BLOCK_SIZE whenever
+			 * info->length is not a multiple of it.
+			 */
+			copy_len = RTE_MIN((uint32_t)SFF_READ_BLOCK_SIZE, info->length - i);
+			memcpy(data + i, value, copy_len);
 		}
 	}
 

  reply	other threads:[~2026-11-13 10:48 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-12 15:07 [PATCH] net/ice: fix trailing bytes drop in get_module_eeprom() Marcel Telka
2026-11-13 10:47 ` Marcel Telka [this message]
2026-11-13 10:53   ` [PATCH v3] " Marcel Telka

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=avbq3hRC0CYC4f_q@telcontar \
    --to=marcel@telka.sk \
    --cc=dev@dpdk.org \
    --cc=stable@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.