Skip to content

Commit 4e9d9d1

Browse files
Dan Carpenterkuba-moo
authored andcommitted
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: 32ab60e ("net: phy: icplus: add MDI/MDIX support for IP101A/G") Fixes: f9bc51e ("net: phy: icplus: fix paged register access") Signed-off-by: Dan Carpenter <[email protected]> Reviewed-by: Michael Walle <[email protected]> Reviewed-by: Russell King <[email protected]> Link: https://lore.kernel.org/r/YC+OpFGsDPXPnXM5@mwanda Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 0a8a800 commit 4e9d9d1

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

drivers/net/phy/icplus.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ static int ip101a_g_config_intr_pin(struct phy_device *phydev)
239239

240240
oldpage = phy_select_page(phydev, IP101G_DEFAULT_PAGE);
241241
if (oldpage < 0)
242-
return oldpage;
242+
goto out;
243243

244244
/* configure the RXER/INTR_32 pin of the 32-pin IP101GR if needed: */
245245
switch (priv->sel_intr32) {
@@ -314,7 +314,7 @@ static int ip101a_g_read_status(struct phy_device *phydev)
314314

315315
oldpage = phy_select_page(phydev, IP101G_DEFAULT_PAGE);
316316
if (oldpage < 0)
317-
return oldpage;
317+
goto out;
318318

319319
ret = __phy_read(phydev, IP10XX_SPEC_CTRL_STATUS);
320320
if (ret < 0)
@@ -349,7 +349,8 @@ static int ip101a_g_read_status(struct phy_device *phydev)
349349
static int ip101a_g_config_mdix(struct phy_device *phydev)
350350
{
351351
u16 ctrl = 0, ctrl2 = 0;
352-
int oldpage, ret;
352+
int oldpage;
353+
int ret = 0;
353354

354355
switch (phydev->mdix_ctrl) {
355356
case ETH_TP_MDI:
@@ -367,7 +368,7 @@ static int ip101a_g_config_mdix(struct phy_device *phydev)
367368

368369
oldpage = phy_select_page(phydev, IP101G_DEFAULT_PAGE);
369370
if (oldpage < 0)
370-
return oldpage;
371+
goto out;
371372

372373
ret = __phy_modify(phydev, IP10XX_SPEC_CTRL_STATUS,
373374
IP101A_G_AUTO_MDIX_DIS, ctrl);

0 commit comments

Comments
 (0)