aeon_ipc_send_msg() ignores the return value of phy_write_mmd() when filling the IPC data registers. On an MDIO failure the command is still issued, and the firmware acts on stale or partial data left in the registers. Check the result of each write and abort the transfer on error, propagating the error code to the caller. Fixes: 830877d89edc ("net: phy: Add support for Aeonsemi AS21xxx PHYs") Signed-off-by: Cristian Ciocaltea <cris…@collabora.com> --- drivers/net/phy/as21xxx.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/net/phy/as21xxx.c b/drivers/net/phy/as21xxx.c index 4e10b0920a3c..14c22cb80db7 100644 --- a/drivers/net/phy/as21xxx.c +++ b/drivers/net/phy/as21xxx.c @@ -475,9 +475,12 @@ static int aeon_ipc_send_msg(struct phy_device *phydev, mutex_lock(&priv->ipc_lock); - for (i = 0; i < data_len / sizeof(u16); i++) - phy_write_mmd(phydev, MDIO_MMD_VEND1, VEND1_IPC_DATA(i), - data[i]); + for (i = 0; i < data_len / sizeof(u16); i++) { + ret = phy_write_mmd(phydev, MDIO_MMD_VEND1, VEND1_IPC_DATA(i), + data[i]); + if (ret < 0) + goto out; + } cmd = FIELD_PREP(AEON_IPC_CMD_SIZE, data_len) | FIELD_PREP(AEON_IPC_CMD_OPCODE, opcode);
-- 2.56.0