diff options
Diffstat (limited to 'fs/anon_inodes.c')
-rw-r--r-- | fs/anon_inodes.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/fs/anon_inodes.c b/fs/anon_inodes.c index 23321889d9b0..f42be069e085 100644 --- a/fs/anon_inodes.c +++ b/fs/anon_inodes.c | |||
@@ -81,13 +81,10 @@ int anon_inode_getfd(int *pfd, struct inode **pinode, struct file **pfile, | |||
81 | 81 | ||
82 | if (IS_ERR(anon_inode_inode)) | 82 | if (IS_ERR(anon_inode_inode)) |
83 | return -ENODEV; | 83 | return -ENODEV; |
84 | file = get_empty_filp(); | ||
85 | if (!file) | ||
86 | return -ENFILE; | ||
87 | 84 | ||
88 | error = get_unused_fd(); | 85 | error = get_unused_fd(); |
89 | if (error < 0) | 86 | if (error < 0) |
90 | goto err_put_filp; | 87 | return error; |
91 | fd = error; | 88 | fd = error; |
92 | 89 | ||
93 | /* | 90 | /* |
@@ -114,14 +111,15 @@ int anon_inode_getfd(int *pfd, struct inode **pinode, struct file **pfile, | |||
114 | dentry->d_flags &= ~DCACHE_UNHASHED; | 111 | dentry->d_flags &= ~DCACHE_UNHASHED; |
115 | d_instantiate(dentry, anon_inode_inode); | 112 | d_instantiate(dentry, anon_inode_inode); |
116 | 113 | ||
117 | file->f_path.mnt = mntget(anon_inode_mnt); | 114 | error = -ENFILE; |
118 | file->f_path.dentry = dentry; | 115 | file = alloc_file(anon_inode_mnt, dentry, |
116 | FMODE_READ | FMODE_WRITE, fops); | ||
117 | if (!file) | ||
118 | goto err_dput; | ||
119 | file->f_mapping = anon_inode_inode->i_mapping; | 119 | file->f_mapping = anon_inode_inode->i_mapping; |
120 | 120 | ||
121 | file->f_pos = 0; | 121 | file->f_pos = 0; |
122 | file->f_flags = O_RDWR; | 122 | file->f_flags = O_RDWR; |
123 | file->f_op = fops; | ||
124 | file->f_mode = FMODE_READ | FMODE_WRITE; | ||
125 | file->f_version = 0; | 123 | file->f_version = 0; |
126 | file->private_data = priv; | 124 | file->private_data = priv; |
127 | 125 | ||
@@ -132,10 +130,10 @@ int anon_inode_getfd(int *pfd, struct inode **pinode, struct file **pfile, | |||
132 | *pfile = file; | 130 | *pfile = file; |
133 | return 0; | 131 | return 0; |
134 | 132 | ||
133 | err_dput: | ||
134 | dput(dentry); | ||
135 | err_put_unused_fd: | 135 | err_put_unused_fd: |
136 | put_unused_fd(fd); | 136 | put_unused_fd(fd); |
137 | err_put_filp: | ||
138 | put_filp(file); | ||
139 | return error; | 137 | return error; |
140 | } | 138 | } |
141 | EXPORT_SYMBOL_GPL(anon_inode_getfd); | 139 | EXPORT_SYMBOL_GPL(anon_inode_getfd); |