patch-2.1.43 linux/kernel/exit.c

Next file: linux/kernel/fork.c
Previous file: linux/init/main.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.42/linux/kernel/exit.c linux/kernel/exit.c
@@ -19,6 +19,7 @@
 #include <linux/smp.h>
 #include <linux/smp_lock.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 
 #include <asm/uaccess.h>
 #include <asm/pgtable.h>
@@ -366,14 +367,18 @@
 		if (i >= NR_OPEN)
 			break;
 		while (set) {
-			if (set & 1)
+			if (set & 1) {
 				close_fp(files->fd[i]);
+				files->fd[i] = NULL;
+			}
 			i++;
 			set >>= 1;
 		}
 	}
 }
 
+extern kmem_cache_t *files_cachep;  
+
 static inline void __exit_files(struct task_struct *tsk)
 {
 	struct files_struct * files = tsk->files;
@@ -382,7 +387,7 @@
 		tsk->files = NULL;
 		if (!--files->count) {
 			close_files(files);
-			kfree(files);
+			kmem_cache_free(files_cachep, files);
 		}
 	}
 }

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