[][kernel][common][eth][Refactor Fiberstore SFP-2.5G-T IOT issue]
[Description]
Refactor Fiberstore SFP-2.5G-T IOT issue.
Without this patch, the kernel may experience a panic at __phy_read_mmd
if phydev lacks an assigned drv pointer.
[Release-log]
N/A
Change-Id: Ib227d2094ec8b81deade26dce0c21effc7e045c0
Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/9915720
diff --git a/21.02/files/target/linux/mediatek/patches-5.4/999-1722-v6.10-net-phy-realtek-add-rtl8221b-series.patch b/21.02/files/target/linux/mediatek/patches-5.4/999-1722-v6.10-net-phy-realtek-add-rtl8221b-series.patch
index 343a31d..4efd873 100644
--- a/21.02/files/target/linux/mediatek/patches-5.4/999-1722-v6.10-net-phy-realtek-add-rtl8221b-series.patch
+++ b/21.02/files/target/linux/mediatek/patches-5.4/999-1722-v6.10-net-phy-realtek-add-rtl8221b-series.patch
@@ -408,7 +408,7 @@
+ return 0;
+
+ rid = phydev->c45_ids.device_ids[1];
-+ if ((rid == 0xffffffff)) {
++ if ((rid == 0xffffffff) && phydev->mdio.bus->read) {
+ int val;
+
+ val = phy_read_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_PKGID1);
diff --git a/21.02/files/target/linux/mediatek/patches-5.4/999-1723-v5.6-net-phy-add-sanity-check-to-read_mmd.patch b/21.02/files/target/linux/mediatek/patches-5.4/999-1723-v5.6-net-phy-add-sanity-check-to-read_mmd.patch
new file mode 100755
index 0000000..83ed0e9
--- /dev/null
+++ b/21.02/files/target/linux/mediatek/patches-5.4/999-1723-v5.6-net-phy-add-sanity-check-to-read_mmd.patch
@@ -0,0 +1,26 @@
+From d4bf301416311b94e509cfb4a937e54e4384d8c2 Mon Sep 17 00:00:00 2001
+From: Bo-Cun Chen <bc-bocun.chen@mediatek.com>
+Date: Wed, 20 Nov 2024 18:08:47 +0800
+Subject: [PATCH] net: phy: add sanity check to read_mmd
+
+Signed-off-by: Bo-Cun Chen <bc-bocun.chen@mediatek.com>
+---
+ drivers/net/phy/phy-core.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/net/phy/phy-core.c b/drivers/net/phy/phy-core.c
+index 96d9e1f..7f7cdbd 100644
+--- a/drivers/net/phy/phy-core.c
++++ b/drivers/net/phy/phy-core.c
+@@ -400,7 +400,7 @@ int __phy_read_mmd(struct phy_device *phydev, int devad, u32 regnum)
+ if (regnum > (u16)~0 || devad > 32)
+ return -EINVAL;
+
+- if (phydev->drv->read_mmd) {
++ if (phydev->drv && phydev->drv->read_mmd) {
+ val = phydev->drv->read_mmd(phydev, devad, regnum);
+ } else if (phydev->is_c45) {
+ u32 addr = MII_ADDR_C45 | (devad << 16) | (regnum & 0xffff);
+--
+2.45.2
+