patch-1.3.95 linux/kernel/exit.c

Next file: linux/kernel/sched.c
Previous file: linux/include/linux/tty.h
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v1.3.94/linux/kernel/exit.c linux/kernel/exit.c
@@ -433,18 +433,19 @@
 	struct mm_struct * mm = current->mm;
 
 	/* Set us up to use the kernel mm state */
-	flush_cache_mm(mm);
-	flush_tlb_mm(mm);
-	init_mm.count++;
-	current->mm = &init_mm;
-	current->swappable = 0;
-	SET_PAGE_DIR(current, swapper_pg_dir);
+	if (mm != &init_mm) {
+		flush_cache_mm(mm);
+		flush_tlb_mm(mm);
+		current->mm = &init_mm;
+		current->swappable = 0;
+		SET_PAGE_DIR(current, swapper_pg_dir);
 
-	/* free the old state - not used any more */
-	if (!--mm->count) {
-		exit_mmap(mm);
-		free_page_tables(mm);
-		kfree(mm);
+		/* free the old state - not used any more */
+		if (!--mm->count) {
+			exit_mmap(mm);
+			free_page_tables(mm);
+			kfree(mm);
+		}
 	}
 }
 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov with Sam's (original) version
of this