Don't try to "validate" a non-existing timeval.
authorLinus Torvalds <torvalds@g5.osdl.org>
Tue, 31 Jan 2006 18:16:55 +0000 (10:16 -0800)
committerLinus Torvalds <torvalds@g5.osdl.org>
Tue, 31 Jan 2006 18:16:55 +0000 (10:16 -0800)
settime() with a NULL timeval is silly but legal.

Noticed by Dave Jones <davej@redhat.com>

Signed-off-by: Linus Torvalds <torvalds@osdl.org>
kernel/time.c
security/seclvl.c

index 7477b1d..1f23e68 100644 (file)
@@ -155,7 +155,7 @@ int do_sys_settimeofday(struct timespec *tv, struct timezone *tz)
        static int firsttime = 1;
        int error = 0;
 
-       if (!timespec_valid(tv))
+       if (tv && !timespec_valid(tv))
                return -EINVAL;
 
        error = security_settime(tv, tz);
index 1caac01..8529ea6 100644 (file)
@@ -368,8 +368,8 @@ static int seclvl_capable(struct task_struct *tsk, int cap)
  */
 static int seclvl_settime(struct timespec *tv, struct timezone *tz)
 {
-       struct timespec now;
-       if (seclvl > 1) {
+       if (tv && seclvl > 1) {
+               struct timespec now;
                now = current_kernel_time();
                if (tv->tv_sec < now.tv_sec ||
                    (tv->tv_sec == now.tv_sec && tv->tv_nsec < now.tv_nsec)) {