ytphy_read_ext() and ytphy_write_ext() access an extended register by writing its number to YTPHY_PAGE_SELECT and then reading or writing YTPHY_PAGE_DATA. Their comments say that the caller must hold the MDIO bus lock, so that no other access to the PHY lands between the two steps. yt8521_led_hw_control_set() and yt8521_led_hw_control_get() call them without it: phy_led_hw_control_set() and phy_led_hw_control_get() only hold phydev->lock. Another user of the bus, for example a WoL query through ytphy_read_ext_with_lock() or a register access from the MAC driver, can then change the selected extended register in between. The LED configuration is then written to a different register, or read from one. Use ytphy_read_ext_with_lock() and ytphy_write_ext_with_lock(), as the rest of the driver does outside locked sections. This was discovered by a static analysis tool: Clang context analysis checking the locking rule in the comments of ytphy_read_ext() and ytphy_write_ext() (an LLM was used to turn the comments into rules). The netdev AI review later pointed out the same problem as pre-existing on the YT8521 led_brightness_set series. The issue was not triggered, and the fix was only build-tested. Fixes: 355b82c54c12 ("net: phy: motorcomm: Add support for PHY LEDs on YT8521") Cc: stable@vger.kernel.org Signed-off-by: Praneeth Balasubramanian --- Notes: This was found by a compiler-based check, part of research at UCSB SecLab. The locking rule stated in the kernel-doc comment of the called function was turned into a Clang context-analysis requirement (__must_hold) on that function, and Clang 23 with CONFIG_WARN_CONTEXT_ANALYSIS then checked every caller. An LLM was used only to turn the comment into a machine-readable rule; the report itself comes from the compiler. The patch and changelog were drafted with Claude Opus 5.5. I reviewed the patch and take responsibility for it. Testing: builds without new warnings with W=1 (x86_64, clang 23, allmodconfig). Not runtime-tested; I do not have this hardware, and I have not observed the race myself. drivers/net/phy/motorcomm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/phy/motorcomm.c b/drivers/net/phy/motorcomm.c index a87e83fdf590..b109b160d681 100644 --- a/drivers/net/phy/motorcomm.c +++ b/drivers/net/phy/motorcomm.c @@ -1836,7 +1836,8 @@ static int yt8521_led_hw_control_set(struct phy_device *phydev, u8 index, if (test_bit(TRIGGER_NETDEV_RX, &rules)) val |= YT8521_LED_RXACT_BLK_EN; - return ytphy_write_ext(phydev, YT8521_LED0_CFG_REG + index, val); + return ytphy_write_ext_with_lock(phydev, YT8521_LED0_CFG_REG + index, + val); } static int yt8521_led_hw_control_get(struct phy_device *phydev, u8 index, @@ -1847,7 +1848,7 @@ static int yt8521_led_hw_control_get(struct phy_device *phydev, u8 index, if (index >= YT8521_MAX_LEDS) return -EINVAL; - val = ytphy_read_ext(phydev, YT8521_LED0_CFG_REG + index); + val = ytphy_read_ext_with_lock(phydev, YT8521_LED0_CFG_REG + index); if (val < 0) return val; -- 2.25.1