net: lan743x: Modify the EEPROM and OTP size for PCI1xxxx devices
Subsystems (3)
PATCH 1/1 net: lan743x: Modify the EEPROM and OTP size for PCI1xxxx devices
Maximum OTP and EEPROM size for hearthstone PCI1xxxx devices are 8 Kb and 64 Kb respectively. Adjust max size definitions and return correct EEPROM length based on device. Also prevent out-of-bound read/write.
Signed-off-by Rengarajan S <[email protected]>
--- .../net/ethernet/microchip/lan743x_ethtool.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)
drivers/net/ethernet/microchip/lan743x_ethtool.c +16 -2
@@ -18,6 +18,8 @@#define EEPROM_MAC_OFFSET (0x01)#define MAX_EEPROM_SIZE (512)#define MAX_OTP_SIZE (1024) +#define MAX_HS_OTP_SIZE (8 * 1024) +#define MAX_HS_EEPROM_SIZE (64 * 1024)#define OTP_INDICATOR_1 (0xF3)#define OTP_INDICATOR_2 (0xF7)
@@ -272,6 +274,9 @@ static int lan743x_hs_otp_read(struct lan743x_adapter *adapter, u32 offset,int ret;int i; +if (offset + length >MAX_HS_OTP_SIZE ) +return -EINVAL ; + ret =lan743x_hs_syslock_acquire (adapter,LOCK_TIMEOUT_MAX_CNT );if (ret <0 )return ret;
@@ -320,6 +325,9 @@ static int lan743x_hs_otp_write(struct lan743x_adapter *adapter, u32 offset,int ret;int i; +if (offset + length >MAX_HS_OTP_SIZE ) +return -EINVAL ; + ret =lan743x_hs_syslock_acquire (adapter,LOCK_TIMEOUT_MAX_CNT );if (ret <0 )return ret;
@@ -497,6 +505,9 @@ static int lan743x_hs_eeprom_read(struct lan743x_adapter *adapter,u32 val;int i; +if (offset + length >MAX_HS_EEPROM_SIZE ) +return -EINVAL ; + retval =lan743x_hs_syslock_acquire (adapter,LOCK_TIMEOUT_MAX_CNT );if (retval <0 )return retval;
@@ -539,6 +550,9 @@ static int lan743x_hs_eeprom_write(struct lan743x_adapter *adapter,u32 val;int i; +if (offset + length >MAX_HS_EEPROM_SIZE ) +return -EINVAL ; + retval =lan743x_hs_syslock_acquire (adapter,LOCK_TIMEOUT_MAX_CNT );if (retval <0 )return retval;
@@ -604,9 +618,9 @@ static int lan743x_ethtool_get_eeprom_len(struct net_device *netdev)struct lan743x_adapter *adapter =netdev_priv (netdev);if (adapter->flags &LAN743X_ADAPTER_FLAG_OTP ) -return MAX_OTP_SIZE ; +return adapter->is_pci11x1x ?MAX_HS_OTP_SIZE :MAX_OTP_SIZE ; -return MAX_EEPROM_SIZE ; +return adapter->is_pci11x1x ?MAX_HS_EEPROM_SIZE :MAX_EEPROM_SIZE ; } static int lan743x_ethtool_get_eeprom(struct net_device *netdev,
Signature · 1 line
2.25.1
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 8 lines · On Fri, 23 May 2025 23:03:26 +0530 you wrote:
Maximum OTP and EEPROM size for hearthstone PCI1xxxx devices are 8 Kb and 64 Kb respectively. Adjust max size definitions and return correct EEPROM length based on device. Also prevent out-of-bound read/write.
Signed-off-by Rengarajan S <[email protected]>--- .../net/ethernet/microchip/lan743x_ethtool.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)
Here is the summary with links:
- [v1,net-next] net: lan743x: Modify the EEPROM and OTP size for PCI1xxxx devices
https://git.kernel.org/netdev/net-next/c/3b9935586a9b
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html