[PATCH net v3 4/4] net: phy: as21xxx: handle odd firmware on loading
From: Christian Marangi
Date: Wed Oct 28 2026 - 03:32:01 EST
Even if firmware for AS21xxx should be always u16 aligned, we can't assume
this will be the same forever. Better address this by simply validate the
index before reading out of bound from the data buffer.
A zero padded buffer will be passed to the AS21xxx mailbox in such case.
Fixes: 830877d89edc ("net: phy: Add support for Aeonsemi AS21xxx PHYs")
Signed-off-by: Christian Marangi <ansuelsmth@xxxxxxxxx>
---
drivers/net/phy/as21xxx.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/net/phy/as21xxx.c b/drivers/net/phy/as21xxx.c
index 81e9827873bf..655127a656c4 100644
--- a/drivers/net/phy/as21xxx.c
+++ b/drivers/net/phy/as21xxx.c
@@ -323,9 +323,11 @@ static int aeon_firmware_boot(struct phy_device *phydev, const u8 *data,
return -EINVAL;
}
- /* Firmware is always aligned to u16 */
+ /* Firmware should be u16 aligned, zero-pad a trailing odd byte */
for (i = 0; i < size; i += 2) {
- val = data[i + 1] << 8 | data[i];
+ val = data[i];
+ if (i + 1 < size)
+ val |= data[i + 1] << 8;
ret = phy_write_mmd(phydev, MDIO_MMD_VEND1,
VEND1_GLB_REG_MDIO_INDIRECT_LOAD, val);
--
2.55.0