mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
tools/thermal/tmon: Fix signed shift UB in binding display
In the thermal zone binding display loop, the expression `(1 << j)` performs a signed integer shift. When j reaches 31, this sets the sign bit of a 32-bit signed integer, which is undefined behavior. Fix it by using `(1U << j)` to perform an unsigned shift. Signed-off-by: Liu Jing <liujing@cmss.chinamobile.com> Signed-off-by: Daniel Lezcano <daniel.lezcano@kernel.org> Link: https://patch.msgid.link/20260903082858.5273-1-liujing@cmss.chinamobile.com
This commit is contained in:
parent
05657c7822
commit
f4428025c8
|
|
@ -171,7 +171,7 @@ static void prepare_logging(void)
|
|||
|
||||
memset(binding_str, 0, sizeof(binding_str));
|
||||
for (j = 0; j < 32; j++)
|
||||
binding_str[j] = (ptdata.tzi[i].cdev_binding & (1 << j)) ?
|
||||
binding_str[j] = (ptdata.tzi[i].cdev_binding & (1U << j)) ?
|
||||
'1' : '0';
|
||||
|
||||
fprintf(tmon_log, "#thermal zone %s%02d cdevs binding: %32s\n",
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user