[PATCH] clocksource/drivers/exynos_mct: Fix an unexpected sign extension

Markov Gleb <[email protected]>
Newsgroups org.kernel.vger.linux-samsung-soc,org.infradead.lists.linux-arm-kernel,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
From: Gleb Markov <[email protected]>

Due to implicit sign extension, shifting a signed iteral 1 before
converting to a wider unsigned type floods the upper bits with ones.
This produced an unexpected value (such as 0xffffffffff80000000), which
breaks subsequent calculations.

Add the UL suffix to explicitly convert to a type with a larger dimension.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: 30d8bead5a30 ("ARM: EXYNOS4: Implement kernel timers using MCT")
Signed-off-by: Gleb Markov <[email protected]>
---
 drivers/clocksource/exynos_mct.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clocksource/exynos_mct.c b/drivers/clocksource/exynos_mct.c
index da09f467a6bb..ab607dc99004 100644
--- a/drivers/clocksource/exynos_mct.c
+++ b/drivers/clocksource/exynos_mct.c
@@ -378,7 +378,7 @@ static void exynos4_mct_tick_start(unsigned long cycles,
 
 	exynos4_mct_tick_stop(mevt);
 
-	tmp = (1 << 31) | cycles;	/* MCT_L_UPDATE_ICNTB */
+	tmp = (1UL << 31) | cycles;	/* MCT_L_UPDATE_ICNTB */
 
 	/* update interrupt count buffer */
 	exynos4_mct_write(tmp, mevt->base + MCT_L_ICNTB_OFFSET);
-- 
2.43.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.