[openwrt/openwrt] ramips: mtk_eth_soc: fix NULL pointer dereference for syncp

LEDE Commits lede-commits at lists.infradead.org
Sun Feb 11 03:21:52 PST 2024


nick pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/88d1322fcfb1ce20613d520aa70e3a1ef63e042d

commit 88d1322fcfb1ce20613d520aa70e3a1ef63e042d
Author: Shiji Yang <yangshiji66 at qq.com>
AuthorDate: Sat Feb 10 20:35:46 2024 +0800

    ramips: mtk_eth_soc: fix NULL pointer dereference for syncp
    
    u64_stats_init() has been unable to handle NULL pointer since
    6.1 kernel. This patch fixes kernel oops on mt76x8 and rt305x
    sub-target.
    
    Signed-off-by: Shiji Yang <yangshiji66 at qq.com>
---
 target/linux/ramips/files/drivers/net/ethernet/ralink/mtk_eth_soc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/target/linux/ramips/files/drivers/net/ethernet/ralink/mtk_eth_soc.c b/target/linux/ramips/files/drivers/net/ethernet/ralink/mtk_eth_soc.c
index 35a3113804..dda9abee49 100644
--- a/target/linux/ramips/files/drivers/net/ethernet/ralink/mtk_eth_soc.c
+++ b/target/linux/ramips/files/drivers/net/ethernet/ralink/mtk_eth_soc.c
@@ -1601,6 +1601,7 @@ static int fe_probe(struct platform_device *pdev)
 			goto err_free_dev;
 		}
 		spin_lock_init(&priv->hw_stats->stats_lock);
+		u64_stats_init(&priv->hw_stats->syncp);
 	}
 
 	sysclk = devm_clk_get(&pdev->dev, NULL);
@@ -1628,7 +1629,6 @@ static int fe_probe(struct platform_device *pdev)
 	priv->tx_ring.tx_ring_size = NUM_DMA_DESC;
 	priv->rx_ring.rx_ring_size = NUM_DMA_DESC;
 	INIT_WORK(&priv->pending_work, fe_pending_work);
-	u64_stats_init(&priv->hw_stats->syncp);
 
 	napi_weight = 16;
 	if (priv->flags & FE_FLAG_NAPI_WEIGHT) {




More information about the lede-commits mailing list