Commit 76ffe688 authored by Linus Torvalds's avatar Linus Torvalds

Fix nanosleep() behaviour with NULL "remaining" argument.

parent cd25ec04
...@@ -1040,7 +1040,7 @@ static long nanosleep_restart(struct restart_block *restart) ...@@ -1040,7 +1040,7 @@ static long nanosleep_restart(struct restart_block *restart)
jiffies_to_timespec(expire, &t); jiffies_to_timespec(expire, &t);
ret = -ERESTART_RESTARTBLOCK; ret = -ERESTART_RESTARTBLOCK;
if (copy_to_user(rmtp, &t, sizeof(t))) if (rmtp && copy_to_user(rmtp, &t, sizeof(t)))
ret = -EFAULT; ret = -EFAULT;
/* The 'restart' block is already filled in */ /* The 'restart' block is already filled in */
} }
...@@ -1067,7 +1067,7 @@ asmlinkage long sys_nanosleep(struct timespec *rqtp, struct timespec *rmtp) ...@@ -1067,7 +1067,7 @@ asmlinkage long sys_nanosleep(struct timespec *rqtp, struct timespec *rmtp)
if (expire) { if (expire) {
struct restart_block *restart; struct restart_block *restart;
jiffies_to_timespec(expire, &t); jiffies_to_timespec(expire, &t);
if (copy_to_user(rmtp, &t, sizeof(t))) if (rmtp && copy_to_user(rmtp, &t, sizeof(t)))
return -EFAULT; return -EFAULT;
restart = &current_thread_info()->restart_block; restart = &current_thread_info()->restart_block;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment