patch-2.1.36 linux/kernel/itimer.c

Next file: linux/kernel/ksyms.c
Previous file: linux/kernel/info.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.35/linux/kernel/itimer.c linux/kernel/itimer.c
@@ -43,7 +43,6 @@
 {
 	value->tv_usec = (jiffies % HZ) * (1000000 / HZ);
 	value->tv_sec = jiffies / HZ;
-	return;
 }
 
 static int _getitimer(int which, struct itimerval *value)
@@ -80,20 +79,18 @@
 	return 0;
 }
 
+/* SMP: Only we modify our itimer values. */
 asmlinkage int sys_getitimer(int which, struct itimerval *value)
 {
 	int error = -EFAULT;
 	struct itimerval get_buffer;
 
-	lock_kernel();
-	if (!value)
-		goto out;
-	error = _getitimer(which, &get_buffer);
-	if (error)
-		goto out;
-	error = copy_to_user(value, &get_buffer, sizeof(get_buffer)) ? -EFAULT : 0;
-out:
-	unlock_kernel();
+	if (value) {
+		error = _getitimer(which, &get_buffer);
+		if (!error)
+			error =	copy_to_user(value, &get_buffer, sizeof(get_buffer))
+				? -EFAULT : 0;
+	}
 	return error;
 }
 
@@ -155,31 +152,27 @@
 	return 0;
 }
 
+/* SMP: Again, only we play with our itimers, and signals are SMP safe
+ *      now so that is not an issue at all anymore.
+ */
 asmlinkage int sys_setitimer(int which, struct itimerval *value, struct itimerval *ovalue)
 {
-	int error;
 	struct itimerval set_buffer, get_buffer;
+	int error;
 
-	lock_kernel();
 	if (value) {
-		error = verify_area(VERIFY_READ, value, sizeof(*value));
-		if (error)
-			goto out;
-		error = copy_from_user(&set_buffer, value, sizeof(set_buffer));
-		if (error) {
-			error = -EFAULT;
-			goto out;
-		}
+		if(verify_area(VERIFY_READ, value, sizeof(*value)))
+			return -EFAULT;
+		if(copy_from_user(&set_buffer, value, sizeof(set_buffer)))
+			return -EFAULT;
 	} else
 		memset((char *) &set_buffer, 0, sizeof(set_buffer));
 
 	error = _setitimer(which, &set_buffer, ovalue ? &get_buffer : 0);
 	if (error || !ovalue)
-		goto out;
+		return error;
 
 	if (copy_to_user(ovalue, &get_buffer, sizeof(get_buffer)))
-		error = -EFAULT; 
-out:
-	unlock_kernel();
-	return error;
+		return -EFAULT; 
+	return 0;
 }

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov