Module Name:    src
Committed By:   martin
Date:           Thu Oct 30 12:18:56 UTC 2014

Modified Files:
        src/sys/compat/netbsd32 [netbsd-7]: netbsd32_compat_50.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #166):
        sys/compat/netbsd32/netbsd32_compat_50.c: revision 1.28
fix multiple mistakes:
- error from copyout was ignored
- the wrong size was specified in copyin
- missing locking.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.24.2.1 src/sys/compat/netbsd32/netbsd32_compat_50.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/compat/netbsd32/netbsd32_compat_50.c
diff -u src/sys/compat/netbsd32/netbsd32_compat_50.c:1.24 src/sys/compat/netbsd32/netbsd32_compat_50.c:1.24.2.1
--- src/sys/compat/netbsd32/netbsd32_compat_50.c:1.24	Tue Jun 24 14:33:57 2014
+++ src/sys/compat/netbsd32/netbsd32_compat_50.c	Thu Oct 30 12:18:56 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_compat_50.c,v 1.24 2014/06/24 14:33:57 maxv Exp $	*/
+/*	$NetBSD: netbsd32_compat_50.c,v 1.24.2.1 2014/10/30 12:18:56 martin Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_50.c,v 1.24 2014/06/24 14:33:57 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_50.c,v 1.24.2.1 2014/10/30 12:18:56 martin Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_sysv.h"
@@ -248,30 +248,31 @@ compat_50_netbsd32_adjtime(struct lwp *l
 		return (error);
 
 	if (SCARG_P32(uap, olddelta)) {
+		mutex_spin_enter(&timecounter_lock);
 		atv.tv_sec = time_adjtime / 1000000;
 		atv.tv_usec = time_adjtime % 1000000;
 		if (atv.tv_usec < 0) {
 			atv.tv_usec += 1000000;
 			atv.tv_sec--;
 		}
-		(void) copyout(&atv,
-			       SCARG_P32(uap, olddelta), 
-			       sizeof(atv));
+		mutex_spin_exit(&timecounter_lock);
+
+		error = copyout(&atv, SCARG_P32(uap, olddelta), sizeof(atv));
 		if (error)
 			return (error);
 	}
 	
 	if (SCARG_P32(uap, delta)) {
-		error = copyin(SCARG_P32(uap, delta), &atv,
-			       sizeof(struct timeval));
+		error = copyin(SCARG_P32(uap, delta), &atv, sizeof(atv));
 		if (error)
 			return (error);
 
+		mutex_spin_enter(&timecounter_lock);
 		time_adjtime = (int64_t)atv.tv_sec * 1000000 + atv.tv_usec;
-
 		if (time_adjtime)
 			/* We need to save the system time during shutdown */
 			time_adjusted |= 1;
+		mutex_spin_exit(&timecounter_lock);
 	}
 
 	return 0;

Reply via email to