lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 17 Mar 2023 13:16:46 +0100
From:   <arturo.buzarra@...i.com>
To:     <netdev@...r.kernel.org>
Subject: [PATCH] net: phy: return EPROBE_DEFER if PHY is not accessible

From: Arturo Buzarra <arturo.buzarra@...i.com>

A PHY driver can dynamically determine the devices features, but in some
circunstances, the PHY is not yet ready and the read capabilities does not fail
but returns an undefined value, so incorrect capabilities are assumed and the
initialization process fails. This commit postpones the PHY probe to ensure the
PHY is accessible.

Signed-off-by: Arturo Buzarra <arturo.buzarra@...i.com>
---
 drivers/net/phy/phy_device.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 1785f1cead97..f8c31e741936 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -2628,10 +2628,14 @@ int genphy_read_abilities(struct phy_device *phydev)
 			       phydev->supported);
 
 	val = phy_read(phydev, MII_BMSR);
 	if (val < 0)
 		return val;
+	if (val == 0x0000 || val == 0xffff) {
+		phydev_err(phydev, "PHY is not accessible\n");
+		return -EPROBE_DEFER;
+	}
 
 	linkmode_mod_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, phydev->supported,
 			 val & BMSR_ANEGCAPABLE);
 
 	linkmode_mod_bit(ETHTOOL_LINK_MODE_100baseT_Full_BIT, phydev->supported,

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ