]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
realtek: dsa: rtl83xx: fix init section mismatch
authorMarkus Stockhausen <markus.stockhausen@gmx.de>
Sun, 25 Jan 2026 08:27:56 +0000 (09:27 +0100)
committerHauke Mehrtens <hauke@hauke-m.de>
Sun, 8 Feb 2026 20:25:29 +0000 (21:25 +0100)
Compilation currently spits this message:

WARNING: modpost: vmlinux: section mismatch in reference:
rtl83xx_sw_probe+0x6a4 (section: .text.rtl83xx_sw_probe)
-> rtl83xx_setup_qos (section: .init.text)

That means that we have a "normal" function caller (can be
called during the whole uptime) and a "initialization" function
callee (only available during init.

Fix this and directly fix the unwanted family checks.

Fixes: 012e0091 ("realtek: dsa: avoid use-after-free")
Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de>
Link: https://github.com/openwrt/openwrt/pull/21690
(cherry picked from commit adbb9a64235e1575bcd47c75d9cdc628b96a15e0)
Link: https://github.com/openwrt/openwrt/pull/21900
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/common.c
target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/qos.c
target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl838x.c
target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl839x.c
target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl83xx.h

index 1f0578ebba74a01a44f512e198772f6ef9aeb379..99c7cf2c25c67abd738fef5b13807a5b33da628f 100644 (file)
@@ -1586,7 +1586,8 @@ static int rtl83xx_sw_probe(struct platform_device *pdev)
 
        rtl83xx_get_l2aging(priv);
 
-       rtl83xx_setup_qos(priv);
+       if (priv->r->qos_init)
+               priv->r->qos_init(priv);
 
        if (priv->r->l3_setup)
                priv->r->l3_setup(priv);
index 1b5b714290af1c313f3aac297f3d265192aae117..ff515bea10838e4c1b1f95a8bf126125df559b95 100644 (file)
@@ -547,24 +547,14 @@ static void rtl839x_config_qos(void)
        }
 }
 
-void __init rtl83xx_setup_qos(struct rtl838x_switch_priv *priv)
+void rtldsa_838x_qos_init(struct rtl838x_switch_priv *priv)
 {
-       switch_priv = priv;
-
-       pr_info("In %s\n", __func__);
-
-       switch (priv->family_id) {
-       case RTL8380_FAMILY_ID:
-               rtl838x_config_qos();
-               rtl838x_rate_control_init(priv);
-               break;
-       case RTL8390_FAMILY_ID:
-               rtl839x_config_qos();
-               rtl839x_rate_control_init(priv);
-               break;
-       default:
-               if (priv->r->qos_init)
-                       priv->r->qos_init(priv);
-               break;
-       }
+       rtl838x_config_qos();
+       rtl838x_rate_control_init(priv);
+}
+
+void rtldsa_839x_qos_init(struct rtl838x_switch_priv *priv)
+{
+       rtl839x_config_qos();
+       rtl839x_rate_control_init(priv);
 }
index 39e15ba3e02b20b568f5c5d5d986699bd5555b71..728190d66729acf17b6bed29236635e19ef33b43 100644 (file)
@@ -1744,6 +1744,7 @@ const struct rtl838x_reg rtl838x_reg = {
        .l3_setup = rtl838x_l3_setup,
        .set_distribution_algorithm = rtl838x_set_distribution_algorithm,
        .set_receive_management_action = rtl838x_set_receive_management_action,
+       .qos_init = rtldsa_838x_qos_init,
 };
 
 irqreturn_t rtl838x_switch_irq(int irq, void *dev_id)
index c63f5cddfc687a8b5cd03c3d3d7883a05cb51c41..711bd9d84f191cde9c4961636d86e862178338aa 100644 (file)
@@ -1713,4 +1713,5 @@ const struct rtl838x_reg rtl839x_reg = {
        .l3_setup = rtl839x_l3_setup,
        .set_distribution_algorithm = rtl839x_set_distribution_algorithm,
        .set_receive_management_action = rtl839x_set_receive_management_action,
+       .qos_init = rtldsa_839x_qos_init,
 };
index a3cb62ceb7ff2263eedb5a2c2fb074555b3206fe..ddee0a0d8a6cd8d79c0c8400c4bc77ef95f25f28 100644 (file)
@@ -131,7 +131,8 @@ inline u16 rtl_table_data(struct table_reg *r, int i);
 inline u32 rtl_table_data_r(struct table_reg *r, int i);
 inline void rtl_table_data_w(struct table_reg *r, u32 v, int i);
 
-void __init rtl83xx_setup_qos(struct rtl838x_switch_priv *priv);
+void rtldsa_838x_qos_init(struct rtl838x_switch_priv *priv);
+void rtldsa_839x_qos_init(struct rtl838x_switch_priv *priv);
 
 void rtl83xx_fast_age(struct dsa_switch *ds, int port);
 int rtl83xx_packet_cntr_alloc(struct rtl838x_switch_priv *priv);