patch-2.3.10 linux/kernel/exit.c

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

diff -u --recursive --new-file v2.3.9/linux/kernel/exit.c linux/kernel/exit.c
@@ -166,11 +166,9 @@
 			break;
 		while (set) {
 			if (set & 1) {
-				struct file * file = files->fd[i];
-				if (file) {
-					files->fd[i] = NULL;
+				struct file * file = xchg(&files->fd[i], NULL);
+				if (file)
 					filp_close(file, files);
-				}
 			}
 			i++;
 			set >>= 1;
@@ -182,10 +180,9 @@
 
 static inline void __exit_files(struct task_struct *tsk)
 {
-	struct files_struct * files = tsk->files;
+	struct files_struct * files = xchg(&tsk->files, NULL);
 
 	if (files) {
-		tsk->files = NULL;
 		if (atomic_dec_and_test(&files->count)) {
 			close_files(files);
 			/*

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