aeon_ipc_send_msg() writes the message payload to the shared VEND1_IPC_DATA registers before taking ipc_lock. Two concurrent senders may interleave, so that one overwrites the payload of the other before the corresponding command is issued. The firmware would then execute a command with the wrong arguments. Take ipc_lock before writing the payload, so that filling the data registers and issuing the command happen atomically with respect to other IPC users. The argument checks remain outside the lock. Fixes: 830877d89edc ("net: phy: Add support for Aeonsemi AS21xxx PHYs") Signed-off-by: Cristian Ciocaltea <cris…@collabora.com> --- drivers/net/phy/as21xxx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/phy/as21xxx.c b/drivers/net/phy/as21xxx.c index 592b4b7a7869..4e10b0920a3c 100644 --- a/drivers/net/phy/as21xxx.c +++ b/drivers/net/phy/as21xxx.c @@ -473,6 +473,8 @@ static int aeon_ipc_send_msg(struct phy_device *phydev, if (data_len > AEON_IPC_DATA_MAX) return -EINVAL; + 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]); @@ -480,8 +482,6 @@ static int aeon_ipc_send_msg(struct phy_device *phydev, cmd = FIELD_PREP(AEON_IPC_CMD_SIZE, data_len) | FIELD_PREP(AEON_IPC_CMD_OPCODE, opcode); - mutex_lock(&priv->ipc_lock); - ret = aeon_ipc_send_cmd(phydev, priv, cmd, &ret_sts); if (ret) { phydev_err(phydev, "failed to send ipc msg for %x: %d\n",
-- 2.56.0