patch-2.4.21 linux-2.4.21/mm/mmap.c

Next file: linux-2.4.21/mm/shmem.c
Previous file: linux-2.4.21/mm/highmem.c
Back to the patch index
Back to the overall index

diff -urN linux-2.4.20/mm/mmap.c linux-2.4.21/mm/mmap.c
@@ -403,10 +403,12 @@
 	if (file && (!file->f_op || !file->f_op->mmap))
 		return -ENODEV;
 
-	if ((len = PAGE_ALIGN(len)) == 0)
+	if (!len)
 		return addr;
 
-	if (len > TASK_SIZE)
+	len = PAGE_ALIGN(len);
+
+	if (len > TASK_SIZE || len == 0)
 		return -EINVAL;
 
 	/* offset overflow? */
@@ -900,6 +902,8 @@
 		break;
 	}
 no_mmaps:
+	if (last < first)
+		return;
 	/*
 	 * If the PGD bits are not consecutive in the virtual address, the
 	 * old method of shifting the VA >> by PGDIR_SHIFT doesn't work.

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)