diff --git a/syscall/time_syscall.c b/syscall/time_syscall.c index e433e2de77b633b239264ddced9cf1f257d7ddb0..ea87f298e5a14f18b82e4a72576d27d3bc460a50 100644 --- a/syscall/time_syscall.c +++ b/syscall/time_syscall.c @@ -356,13 +356,18 @@ int SysNanoSleep(const struct timespec *rqtp, struct timespec *rmtp) { int ret; struct timespec srqtp; - struct timespec srmtp = { 0 }; + struct timespec srmtp; if (!rqtp || LOS_ArchCopyFromUser(&srqtp, rqtp, sizeof(struct timespec))) { errno = EFAULT; return -EFAULT; } + if (rmtp && LOS_ArchCopyFromUser(&srmtp, rmtp, sizeof(struct timespec))) { + errno = EFAULT; + return -EFAULT; + } + ret = nanosleep(&srqtp, rmtp ? &srmtp : NULL); if (ret < 0) { return -get_errno();