[openwrt/openwrt] realtek: fix kernel panic in DSA driver for 5.10

LEDE Commits lede-commits at lists.infradead.org
Sat Sep 25 15:37:41 PDT 2021


adrian pushed a commit to openwrt/openwrt.git, branch master:
https://git.openwrt.org/2e676c05dccc7d5c5cf4ab118f479471be52194a

commit 2e676c05dccc7d5c5cf4ab118f479471be52194a
Author: INAGAKI Hiroshi <musashino.open at gmail.com>
AuthorDate: Sat May 8 17:28:58 2021 +0900

    realtek: fix kernel panic in DSA driver for 5.10
    
    dsa_to_port function in 5.10 returns dsa_port from the port list in
    dsa_switch_tree, but the tree is built when the switch is registered
    by dsa_register_switch and it's null in rtl83xx_mdio_probe.
    
    So, we need to use dsa_to_port after the registration of the switch.
    
    Signed-off-by: INAGAKI Hiroshi <musashino.open at gmail.com>
---
 .../linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/common.c  | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/common.c b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/common.c
index ad69debcc8..25ac2d4679 100644
--- a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/common.c
+++ b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/common.c
@@ -302,8 +302,6 @@ static int __init rtl83xx_mdio_probe(struct rtl838x_switch_priv *priv)
 		if (of_property_read_u32(dn, "reg", &pn))
 			continue;
 
-		priv->ports[pn].dp = dsa_to_port(priv->ds, pn);
-
 		// Check for the integrated SerDes of the RTL8380M first
 		if (of_property_read_bool(dn, "phy-is-integrated")
 			&& priv->id == 0x8380 && pn >= 24) {
@@ -627,6 +625,14 @@ static int __init rtl83xx_sw_probe(struct platform_device *pdev)
 		return err;
 	}
 
+	/*
+	 * dsa_to_port returns dsa_port from the port list in
+	 * dsa_switch_tree, the tree is built when the switch
+	 * is registered by dsa_register_switch
+	 */
+	for (i = 0; i <= priv->cpu_port; i++)
+		priv->ports[i].dp = dsa_to_port(priv->ds, i);
+
 	/* Enable link and media change interrupts. Are the SERDES masks needed? */
 	sw_w32_mask(0, 3, priv->r->isr_glb_src);
 



More information about the lede-commits mailing list