Skip to content

Commit b111df8

Browse files
committed
y2038: alarm: fix half-second cut-off
Changing alarm_itimer accidentally broke the logic for arithmetic rounding of half seconds in the return code. Change it to a constant based on NSEC_PER_SEC, as suggested by Ben Hutchings. Fixes: bd40a17 ("y2038: itimer: change implementation to timespec64") Reported-by: Ben Hutchings <[email protected]> Signed-off-by: Arnd Bergmann <[email protected]>
1 parent af37846 commit b111df8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

kernel/time/itimer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ static unsigned int alarm_setitimer(unsigned int seconds)
297297
* better return too much than too little anyway
298298
*/
299299
if ((!it_old.it_value.tv_sec && it_old.it_value.tv_nsec) ||
300-
it_old.it_value.tv_nsec >= 500000)
300+
it_old.it_value.tv_nsec >= (NSEC_PER_SEC / 2))
301301
it_old.it_value.tv_sec++;
302302

303303
return it_old.it_value.tv_sec;

0 commit comments

Comments
 (0)