Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: phy: icplus: call phy_restore_page() when phy_select_page() fails

The comments to phy_select_page() say that "phy_restore_page() must
always be called after this, irrespective of success or failure of this
call." If we don't call phy_restore_page() then we are still holding
the phy_lock_mdio_bus() so it eventually leads to a dead lock.

Fixes: 32ab60e53920 ("net: phy: icplus: add MDI/MDIX support for IP101A/G")
Fixes: f9bc51e6cce2 ("net: phy: icplus: fix paged register access")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Michael Walle <michael@walle.cc>
Reviewed-by: Russell King <rmk+kernel@armlinux.org.uk>
Link: https://lore.kernel.org/r/YC+OpFGsDPXPnXM5@mwanda
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Dan Carpenter and committed by
Jakub Kicinski
4e9d9d1f 0a8a8000

+5 -4
+5 -4
drivers/net/phy/icplus.c
··· 239 239 240 240 oldpage = phy_select_page(phydev, IP101G_DEFAULT_PAGE); 241 241 if (oldpage < 0) 242 - return oldpage; 242 + goto out; 243 243 244 244 /* configure the RXER/INTR_32 pin of the 32-pin IP101GR if needed: */ 245 245 switch (priv->sel_intr32) { ··· 314 314 315 315 oldpage = phy_select_page(phydev, IP101G_DEFAULT_PAGE); 316 316 if (oldpage < 0) 317 - return oldpage; 317 + goto out; 318 318 319 319 ret = __phy_read(phydev, IP10XX_SPEC_CTRL_STATUS); 320 320 if (ret < 0) ··· 349 349 static int ip101a_g_config_mdix(struct phy_device *phydev) 350 350 { 351 351 u16 ctrl = 0, ctrl2 = 0; 352 - int oldpage, ret; 352 + int oldpage; 353 + int ret = 0; 353 354 354 355 switch (phydev->mdix_ctrl) { 355 356 case ETH_TP_MDI: ··· 368 367 369 368 oldpage = phy_select_page(phydev, IP101G_DEFAULT_PAGE); 370 369 if (oldpage < 0) 371 - return oldpage; 370 + goto out; 372 371 373 372 ret = __phy_modify(phydev, IP10XX_SPEC_CTRL_STATUS, 374 373 IP101A_G_AUTO_MDIX_DIS, ctrl);