From: Arnd Bergmann Date: Mon, 25 Nov 2019 20:25:46 +0000 (+0100) Subject: y2038: alarm: fix half-second cut-off X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=b111df8447acdeb4b9220f99d5d4b28f83eb56ad;p=linux.git 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: bd40a175769d ("y2038: itimer: change implementation to timespec64") Reported-by: Ben Hutchings Signed-off-by: Arnd Bergmann --- diff --git a/kernel/time/itimer.c b/kernel/time/itimer.c index 5872db9bd5f76..9e59c9ea92aa6 100644 --- a/kernel/time/itimer.c +++ b/kernel/time/itimer.c @@ -297,7 +297,7 @@ static unsigned int alarm_setitimer(unsigned int seconds) * better return too much than too little anyway */ if ((!it_old.it_value.tv_sec && it_old.it_value.tv_nsec) || - it_old.it_value.tv_nsec >= 500000) + it_old.it_value.tv_nsec >= (NSEC_PER_SEC / 2)) it_old.it_value.tv_sec++; return it_old.it_value.tv_sec;