From: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
To: Christian Marangi <ansuelsmth@gmail.com>,
Andrew Lunn <andrew@lunn.ch>,
Heiner Kallweit <hkallweit1@gmail.com>,
Russell King <linux@armlinux.org.uk>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.com>
Cc: kernel@collabora.com, netdev@vger.kernel.org
Subject: [PATCH net 02/14] net: phy: as21xxx: handle odd firmware on loading
Date: Mon, 30 Nov 2026 02:55:09 +0200 [thread overview]
Message-ID: <20261130-as21xxx-fixes-v1-2-1bd2eae6ccbc@collabora.com> (raw)
In-Reply-To: <20261130-as21xxx-fixes-v1-0-1bd2eae6ccbc@collabora.com>
From: Christian Marangi <ansuelsmth@gmail.com>
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@gmail.com>
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
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 3db455314b67..5fb06cd765cf 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.56.0
next prev parent reply other threads:[~2026-11-30 0:55 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-30 0:55 [PATCH net 00/14] net: phy: as21xxx: Fix a batch of driver issues Cristian Ciocaltea
2026-11-30 0:55 ` [PATCH net 01/14] net: phy: as21xxx: handle stale link status during autoneg Cristian Ciocaltea
2026-11-30 0:55 ` Cristian Ciocaltea [this message]
2026-11-30 0:55 ` [PATCH net 03/14] net: phy: as21xxx: Fix LED index bounds check Cristian Ciocaltea
2026-11-30 0:55 ` [PATCH net 04/14] net: phy: as21xxx: Use the correct mask for the speed status Cristian Ciocaltea
2026-11-30 0:55 ` [PATCH net 05/14] net: phy: as21xxx: Correct the 10M speed status value Cristian Ciocaltea
2026-11-30 0:55 ` [PATCH net 06/14] net: phy: as21xxx: Do not write the IPC reply to a NULL buffer Cristian Ciocaltea
2026-11-30 0:55 ` [PATCH net 07/14] net: phy: as21xxx: Write IPC payload under ipc_lock Cristian Ciocaltea
2026-11-30 0:55 ` [PATCH net 08/14] net: phy: as21xxx: Handle IPC payload write errors Cristian Ciocaltea
2026-11-30 0:55 ` [PATCH net 09/14] net: phy: as21xxx: Reject odd IPC payload lengths Cristian Ciocaltea
2026-11-30 0:55 ` [PATCH net 10/14] net: phy: as21xxx: Fix LED hw control set for unsupported rules Cristian Ciocaltea
2026-11-30 0:55 ` [PATCH net 11/14] net: phy: as21xxx: Read 10/100/1000 link modes from C22 advertisement Cristian Ciocaltea
2026-11-30 0:55 ` [PATCH net 12/14] net: phy: as21xxx: Configure autoneg advertisement via IPC Cristian Ciocaltea
2026-11-30 0:55 ` [PATCH net 13/14] net: phy: as21xxx: Fix speed and duplex reporting Cristian Ciocaltea
2026-11-30 0:55 ` [PATCH net 14/14] net: phy: as21xxx: Release reset before reading ID in match Cristian Ciocaltea
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=20261130-as21xxx-fixes-v1-2-1bd2eae6ccbc@collabora.com \
--to=cristian.ciocaltea@collabora.com \
--cc=andrew@lunn.ch \
--cc=ansuelsmth@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=hkallweit1@gmail.com \
--cc=kernel@collabora.com \
--cc=kuba@kernel.org \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox