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]
Message-Id: <20220316075953.61398-1-andy.chiu@sifive.com>
Date:   Wed, 16 Mar 2022 15:59:53 +0800
From:   Andy Chiu <andy.chiu@...ive.com>
To:     davem@...emloft.net, kuba@...nel.org, michal.simek@...inx.com,
        linux@...linux.org.uk, robert.hancock@...ian.co, andrew@...n.ch,
        netdev@...r.kernel.org
Cc:     Andy Chiu <andy.chiu@...ive.com>,
        Greentime Hu <greentime.hu@...ive.com>
Subject: [PATCH] net: axiemac: use a phandle to reference pcs_phy

The `of_mdio_find_device()` would get a reference to `mdio_device` by
a given device tree node. Thus, getting a reference to the internal
PCS/PMA PHY by `lp->phy_node` is incorrect since "phy-handle" in the DT
sould point to the external PHY. This incorrect use of "phy-hanlde"
would cause a problem when the driver called `phylink_of_phy_connect()`,
where it would use "phy-handle" in the DT to connect the external PHY.
To fix it, we could add a phandle, "pcs-phy", in the DT so that it would
point to the internal PHY. And the driver would get the correct address
of PCS/PHY.

Fixes: 1a02556086fc (net: axienet: Properly handle PCS/PMA PHY for 1000BaseX mode)
Signed-off-by: Andy Chiu <andy.chiu@...ive.com>
Reviewed-by: Greentime Hu <greentime.hu@...ive.com>
---
 drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
index 6fd5157f0a6d..293189aab4e6 100644
--- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
+++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
@@ -2073,12 +2073,15 @@ static int axienet_probe(struct platform_device *pdev)
 	}
 	if (lp->phy_mode == PHY_INTERFACE_MODE_SGMII ||
 	    lp->phy_mode == PHY_INTERFACE_MODE_1000BASEX) {
-		if (!lp->phy_node) {
-			dev_err(&pdev->dev, "phy-handle required for 1000BaseX/SGMII\n");
+		np = of_parse_phandle(pdev->dev.of_node, "pcs-phy", 0);
+		if (!lp->phy_node || !np) {
+			dev_err(&pdev->dev, "phy-handle and pcs-phy are required for 1000BaseX/SGMII\n");
+			of_node_put(np);
 			ret = -EINVAL;
 			goto cleanup_mdio;
 		}
-		lp->pcs_phy = of_mdio_find_device(lp->phy_node);
+		lp->pcs_phy = of_mdio_find_device(np);
+		of_node_put(np);
 		if (!lp->pcs_phy) {
 			ret = -EPROBE_DEFER;
 			goto cleanup_mdio;
-- 
2.34.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ