net: designware: Fix get_timer value overflow
authorJim Liu <jim.t90615@gmail.com>
Thu, 7 Aug 2025 05:28:32 +0000 (13:28 +0800)
committerJerome Forissier <jerome.forissier@linaro.org>
Mon, 18 Aug 2025 12:08:57 +0000 (14:08 +0200)
get_timer returns a ulong value representing system time in ms.
On a 64-bit system, this ulong value is 64 bits long. However,
the driver stores it in a 32-bit unsigned integer, which overflows
after 49 days up time, causing the driver to get an incorrect time.

Replace the unsigned int variable with a ulong type to properly store
the value returned by get_timer.

Signed-off-by: Stanley Chu <yschu@nuvoton.com>
Signed-off-by: Jim Liu <JJLIU0@nuvoton.com>
drivers/net/designware.c

index fce3ef9..7ecedc3 100644 (file)
@@ -486,7 +486,7 @@ static int dw_adjust_link(struct dw_eth_dev *priv, struct eth_mac_regs *mac_p,
 
 #ifdef CONFIG_ARCH_NPCM8XX
        if (phydev->interface == PHY_INTERFACE_MODE_SGMII) {
-               unsigned int start;
+               ulong start;
 
                /* Indirect access to VR_MII_MMD registers */
                writew((VR_MII_MMD >> 9), PCS_BA + PCS_IND_AC);
@@ -532,7 +532,7 @@ int designware_eth_init(struct dw_eth_dev *priv, u8 *enetaddr)
 {
        struct eth_mac_regs *mac_p = priv->mac_regs_p;
        struct eth_dma_regs *dma_p = priv->dma_regs_p;
-       unsigned int start;
+       ulong start;
        int ret;
 
        writel(readl(&dma_p->busmode) | DMAMAC_SRST, &dma_p->busmode);