diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2018-07-09 11:24:21 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2018-07-10 23:29:03 -0400 |
commit | e8cff84faa4ddb6716caed085f515fbb1d856099 (patch) | |
tree | b94cd77e00da1ef37a4ede44942461ed1509b970 | |
parent | c7e9075fb89362812059fbf8e25bb4a6e825c4c5 (diff) |
fold security_file_free() into file_free()
.. and the call of file_free() in case of security_file_alloc() failure
in get_empty_filp() should be simply file_free_rcu() - no point in
rcu-delays there, anyway.
Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r-- | fs/file_table.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/fs/file_table.c b/fs/file_table.c index 7ec0b3e5f05d..eee7cf629e52 100644 --- a/fs/file_table.c +++ b/fs/file_table.c | |||
@@ -51,6 +51,7 @@ static void file_free_rcu(struct rcu_head *head) | |||
51 | 51 | ||
52 | static inline void file_free(struct file *f) | 52 | static inline void file_free(struct file *f) |
53 | { | 53 | { |
54 | security_file_free(f); | ||
54 | percpu_counter_dec(&nr_files); | 55 | percpu_counter_dec(&nr_files); |
55 | call_rcu(&f->f_u.fu_rcuhead, file_free_rcu); | 56 | call_rcu(&f->f_u.fu_rcuhead, file_free_rcu); |
56 | } | 57 | } |
@@ -123,11 +124,10 @@ struct file *get_empty_filp(void) | |||
123 | if (unlikely(!f)) | 124 | if (unlikely(!f)) |
124 | return ERR_PTR(-ENOMEM); | 125 | return ERR_PTR(-ENOMEM); |
125 | 126 | ||
126 | percpu_counter_inc(&nr_files); | ||
127 | f->f_cred = get_cred(cred); | 127 | f->f_cred = get_cred(cred); |
128 | error = security_file_alloc(f); | 128 | error = security_file_alloc(f); |
129 | if (unlikely(error)) { | 129 | if (unlikely(error)) { |
130 | file_free(f); | 130 | file_free_rcu(&f->f_u.fu_rcuhead); |
131 | return ERR_PTR(error); | 131 | return ERR_PTR(error); |
132 | } | 132 | } |
133 | 133 | ||
@@ -137,6 +137,7 @@ struct file *get_empty_filp(void) | |||
137 | mutex_init(&f->f_pos_lock); | 137 | mutex_init(&f->f_pos_lock); |
138 | eventpoll_init_file(f); | 138 | eventpoll_init_file(f); |
139 | /* f->f_version: 0 */ | 139 | /* f->f_version: 0 */ |
140 | percpu_counter_inc(&nr_files); | ||
140 | return f; | 141 | return f; |
141 | 142 | ||
142 | over: | 143 | over: |
@@ -207,7 +208,6 @@ static void __fput(struct file *file) | |||
207 | } | 208 | } |
208 | if (file->f_op->release) | 209 | if (file->f_op->release) |
209 | file->f_op->release(inode, file); | 210 | file->f_op->release(inode, file); |
210 | security_file_free(file); | ||
211 | if (unlikely(S_ISCHR(inode->i_mode) && inode->i_cdev != NULL && | 211 | if (unlikely(S_ISCHR(inode->i_mode) && inode->i_cdev != NULL && |
212 | !(file->f_mode & FMODE_PATH))) { | 212 | !(file->f_mode & FMODE_PATH))) { |
213 | cdev_put(inode->i_cdev); | 213 | cdev_put(inode->i_cdev); |
@@ -302,10 +302,8 @@ EXPORT_SYMBOL(fput); | |||
302 | 302 | ||
303 | void put_filp(struct file *file) | 303 | void put_filp(struct file *file) |
304 | { | 304 | { |
305 | if (atomic_long_dec_and_test(&file->f_count)) { | 305 | if (atomic_long_dec_and_test(&file->f_count)) |
306 | security_file_free(file); | ||
307 | file_free(file); | 306 | file_free(file); |
308 | } | ||
309 | } | 307 | } |
310 | 308 | ||
311 | void __init files_init(void) | 309 | void __init files_init(void) |