net/ice: fix module EEPROM read
Checks
Commit Message
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
> -----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
@@ -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);
}
}