mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] tools intel-speed-select: Fix signed shift UB in BIT() macro
@ 2026-09-03  8:28 liujing
  2026-09-10  1:06 ` srinivas pandruvada
  0 siblings, 1 reply; 2+ messages in thread
From: liujing @ 2026-09-03  8:28 UTC (permalink / raw)
  To: Srinivas Pandruvada; +Cc: platform-driver-x86, linux-kernel, Liu Jing

From: Liu Jing <liujing@cmss.chinamobile.com>

The BIT() macro is defined as `(1 << (x))` with a signed integer 1.
When x >= 31, this causes signed integer overflow which is undefined
behavior in C. This macro is used with BIT(31) in isst-core.c and
isst-core-mbox.c.

Fix it by using `1U` instead of `1` to perform an unsigned shift,
matching the kernel's own BIT() definition which uses unsigned.

Signed-off-by: Liu Jing <liujing@cmss.chinamobile.com>
---
--- a/tools/power/x86/intel-speed-select/isst.h
+++ b/tools/power/x86/intel-speed-select/isst.h
@@ -30,7 +30,7 @@
 
 #include <linux/isst_if.h>
 
-#define BIT(x) (1 << (x))
+#define BIT(x) (1U << (x))
 #define BIT_ULL(nr) (1ULL << (nr))
 #define GENMASK(h, l) (((~0UL) << (l)) & (~0UL >> (sizeof(long) * 8 - 1 - (h))))
 #define GENMASK_ULL(h, l)                                                      \





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-09-10  1:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-03  8:28 [PATCH] tools intel-speed-select: Fix signed shift UB in BIT() macro liujing
2026-09-10  1:06 ` srinivas pandruvada

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®