diff options
-rw-r--r-- | fs/binfmt_elf.c | 6 | ||||
-rw-r--r-- | fs/binfmt_misc.c | 6 | ||||
-rw-r--r-- | fs/exec.c | 3 | ||||
-rw-r--r-- | include/linux/file.h | 1 | ||||
-rw-r--r-- | kernel/exit.c | 12 |
5 files changed, 18 insertions, 10 deletions
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index dfd8cfb7fb5d..bb43da5cde5c 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c | |||
@@ -1038,10 +1038,8 @@ out_free_interp: | |||
1038 | out_free_file: | 1038 | out_free_file: |
1039 | sys_close(elf_exec_fileno); | 1039 | sys_close(elf_exec_fileno); |
1040 | out_free_fh: | 1040 | out_free_fh: |
1041 | if (files) { | 1041 | if (files) |
1042 | put_files_struct(current->files); | 1042 | reset_files_struct(current, files); |
1043 | current->files = files; | ||
1044 | } | ||
1045 | out_free_ph: | 1043 | out_free_ph: |
1046 | kfree(elf_phdata); | 1044 | kfree(elf_phdata); |
1047 | goto out; | 1045 | goto out; |
diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c index 66ba137f8661..1713c48fef54 100644 --- a/fs/binfmt_misc.c +++ b/fs/binfmt_misc.c | |||
@@ -215,10 +215,8 @@ _error: | |||
215 | bprm->interp_flags = 0; | 215 | bprm->interp_flags = 0; |
216 | bprm->interp_data = 0; | 216 | bprm->interp_data = 0; |
217 | _unshare: | 217 | _unshare: |
218 | if (files) { | 218 | if (files) |
219 | put_files_struct(current->files); | 219 | reset_files_struct(current, files); |
220 | current->files = files; | ||
221 | } | ||
222 | goto _ret; | 220 | goto _ret; |
223 | } | 221 | } |
224 | 222 | ||
@@ -898,8 +898,7 @@ int flush_old_exec(struct linux_binprm * bprm) | |||
898 | return 0; | 898 | return 0; |
899 | 899 | ||
900 | mmap_failed: | 900 | mmap_failed: |
901 | put_files_struct(current->files); | 901 | reset_files_struct(current, files); |
902 | current->files = files; | ||
903 | out: | 902 | out: |
904 | return retval; | 903 | return retval; |
905 | } | 904 | } |
diff --git a/include/linux/file.h b/include/linux/file.h index 9f7c2513866f..74183e6f7f45 100644 --- a/include/linux/file.h +++ b/include/linux/file.h | |||
@@ -112,5 +112,6 @@ struct task_struct; | |||
112 | 112 | ||
113 | struct files_struct *get_files_struct(struct task_struct *); | 113 | struct files_struct *get_files_struct(struct task_struct *); |
114 | void FASTCALL(put_files_struct(struct files_struct *fs)); | 114 | void FASTCALL(put_files_struct(struct files_struct *fs)); |
115 | void reset_files_struct(struct task_struct *, struct files_struct *); | ||
115 | 116 | ||
116 | #endif /* __LINUX_FILE_H */ | 117 | #endif /* __LINUX_FILE_H */ |
diff --git a/kernel/exit.c b/kernel/exit.c index d891883420f7..4b6fb054b25d 100644 --- a/kernel/exit.c +++ b/kernel/exit.c | |||
@@ -487,6 +487,18 @@ void fastcall put_files_struct(struct files_struct *files) | |||
487 | 487 | ||
488 | EXPORT_SYMBOL(put_files_struct); | 488 | EXPORT_SYMBOL(put_files_struct); |
489 | 489 | ||
490 | void reset_files_struct(struct task_struct *tsk, struct files_struct *files) | ||
491 | { | ||
492 | struct files_struct *old; | ||
493 | |||
494 | old = tsk->files; | ||
495 | task_lock(tsk); | ||
496 | tsk->files = files; | ||
497 | task_unlock(tsk); | ||
498 | put_files_struct(old); | ||
499 | } | ||
500 | EXPORT_SYMBOL(reset_files_struct); | ||
501 | |||
490 | static inline void __exit_files(struct task_struct *tsk) | 502 | static inline void __exit_files(struct task_struct *tsk) |
491 | { | 503 | { |
492 | struct files_struct * files = tsk->files; | 504 | struct files_struct * files = tsk->files; |