[PATCH net v2 4/4] net: phy: as21xxx: handle odd firmware on loading

From: Christian Marangi

Date: Thu Oct 22 2026 - 18:30:35 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>
---
Changes v2:
- Add this patch

drivers/net/phy/as21xxx.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/phy/as21xxx.c b/drivers/net/phy/as21xxx.c
index e2988cb10c04..db1a7cd68cef 100644
--- a/drivers/net/phy/as21xxx.c
+++ b/drivers/net/phy/as21xxx.c
@@ -325,7 +325,9 @@ static int aeon_firmware_boot(struct phy_device *phydev, const u8 *data,

/* Firmware is always aligned to u16 */
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