sched/clock: add nsec range check in clock_settime

MIRTOS-109

Return error when tv_nsec <0 or >=1000 million.

Change-Id: Iddbbcda163cb402551f619efb7486f6798859d57
Signed-off-by: Peter Bee <bijunda1@xiaomi.com>
This commit is contained in:
Peter Bee 2021-01-20 18:26:32 +08:00 committed by Gustavo Henrique Nihei
parent 95b5dc523e
commit 8a47dd95c9
1 changed files with 2 additions and 1 deletions

View File

@ -64,7 +64,8 @@ int clock_settime(clockid_t clock_id, FAR const struct timespec *tp)
* time clock.
*/
if (clock_id == CLOCK_REALTIME)
if (clock_id == CLOCK_REALTIME &&
tp->tv_nsec >= 0 && tp->tv_nsec < 1000000000)
{
#ifndef CONFIG_CLOCK_TIMEKEEPING
/* Interrupts are disabled here so that the in-memory time