Skip to content

Commit d185911

Browse files
Tigran Sogomonianbonzini
authored andcommitted
hw/misc: use extract64 instead of 1 << i
1 << i is casted to uint64_t while bitwise and with val. So this value may become 0xffffffff80000000 but only 31th "start" bit is required. Use the bitfield extract() API instead. Found by Linux Verification Center (linuxtesting.org) with SVACE. Signed-off-by: Tigran Sogomonian <[email protected]> Reviewed-by: Alex Bennée <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Paolo Bonzini <[email protected]>
1 parent aa90f11 commit d185911

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

hw/misc/mps2-fpgaio.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ static void mps2_fpgaio_write(void *opaque, hwaddr offset, uint64_t value,
198198

199199
s->led0 = value & MAKE_64BIT_MASK(0, s->num_leds);
200200
for (i = 0; i < s->num_leds; i++) {
201-
led_set_state(s->led[i], value & (1 << i));
201+
led_set_state(s->led[i], extract64(value, i, 1));
202202
}
203203
}
204204
break;

0 commit comments

Comments
 (0)