summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2018-07-09 11:24:21 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2018-07-10 23:29:03 -0400
commite8cff84faa4ddb6716caed085f515fbb1d856099 (patch)
treeb94cd77e00da1ef37a4ede44942461ed1509b970 /fs
parentc7e9075fb89362812059fbf8e25bb4a6e825c4c5 (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>
Diffstat (limited to 'fs')
-rw-r--r--fs/file_table.c10
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)
static inline void file_free(struct file *f)
{
+ security_file_free(f);
percpu_counter_dec(&nr_files);
call_rcu(&f->f_u.fu_rcuhead, file_free_rcu);
}
@@ -123,11 +124,10 @@ struct file *get_empty_filp(void)
if (unlikely(!f))
return ERR_PTR(-ENOMEM);
- percpu_counter_inc(&nr_files);
f->f_cred = get_cred(cred);
error = security_file_alloc(f);
if (unlikely(error)) {
- file_free(f);
+ file_free_rcu(&f->f_u.fu_rcuhead);
return ERR_PTR(error);
}
@@ -137,6 +137,7 @@ struct file *get_empty_filp(void)
mutex_init(&f->f_pos_lock);
eventpoll_init_file(f);
/* f->f_version: 0 */
+ percpu_counter_inc(&nr_files);
return f;
over:
@@ -207,7 +208,6 @@ static void __fput(struct file *file)
}
if (file->f_op->release)
file->f_op->release(inode, file);
- security_file_free(file);
if (unlikely(S_ISCHR(inode->i_mode) && inode->i_cdev != NULL &&
!(file->f_mode & FMODE_PATH))) {
cdev_put(inode->i_cdev);
@@ -302,10 +302,8 @@ EXPORT_SYMBOL(fput);
void put_filp(struct file *file)
{
- if (atomic_long_dec_and_test(&file->f_count)) {
- security_file_free(file);
+ if (atomic_long_dec_and_test(&file->f_count))
file_free(file);
- }
}
void __init files_init(void)