patch-2.1.106 linux/mm/mprotect.c
Next file: linux/mm/mremap.c
Previous file: linux/mm/mmap.c
Back to the patch index
Back to the overall index
-  Lines: 34
-  Date:
Tue Jun  9 10:33:10 1998
-  Orig file: 
v2.1.105/linux/mm/mprotect.c
-  Orig date: 
Thu Mar 26 15:57:06 1998
diff -u --recursive --new-file v2.1.105/linux/mm/mprotect.c linux/mm/mprotect.c
@@ -208,18 +208,20 @@
 	struct vm_area_struct * vma, * next;
 	int error = -EINVAL;
 
-	lock_kernel();
 	if (start & ~PAGE_MASK)
-		goto out;
+		return -EINVAL;
 	len = (len + ~PAGE_MASK) & PAGE_MASK;
 	end = start + len;
 	if (end < start)
-		goto out;
+		return -EINVAL;
 	if (prot & ~(PROT_READ | PROT_WRITE | PROT_EXEC))
-		goto out;
-	error = 0;
+		return -EINVAL;
 	if (end == start)
-		goto out;
+		return 0;
+
+	down(¤t->mm->mmap_sem);
+	lock_kernel();
+
 	vma = find_vma(current->mm, start);
 	error = -EFAULT;
 	if (!vma || vma->vm_start > start)
@@ -256,5 +258,6 @@
 	merge_segments(current->mm, start, end);
 out:
 	unlock_kernel();
+	up(¤t->mm->mmap_sem);
 	return error;
 }
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov