[PATCH 17/19] watchdog: imx28: use correct constant for computing timeout_max

Ahmad Fatoum a.fatoum at pengutronix.de
Mon Jun 12 06:02:38 PDT 2023


timeout_max is a 32-bit variable, so storing ULONG_MAX / WDOG_TICK_RATE
into it causes a wrap around on 64-bit systems. As the SoC is a 32-bit
one, it's likely the original intention was for it to be U32_MAX
instead.

Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 drivers/watchdog/im28wd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/watchdog/im28wd.c b/drivers/watchdog/im28wd.c
index 7df2e2d99506..b52e5851750b 100644
--- a/drivers/watchdog/im28wd.c
+++ b/drivers/watchdog/im28wd.c
@@ -187,7 +187,7 @@ static int imx28_wd_probe(struct device *dev)
 		return PTR_ERR(iores);
 	priv->regs = IOMEM(iores->start);
 	priv->wd.set_timeout = imx28_watchdog_set_timeout;
-	priv->wd.timeout_max = ULONG_MAX / WDOG_TICK_RATE;
+	priv->wd.timeout_max = U32_MAX / WDOG_TICK_RATE;
 	priv->wd.hwdev = dev;
 
 	if (!(readl(priv->regs + MXS_RTC_STAT) & MXS_RTC_STAT_WD_PRESENT)) {
-- 
2.39.2




More information about the barebox mailing list