aboutsummaryrefslogtreecommitdiffstats
path: root/fs/anon_inodes.c
diff options
context:
space:
mode:
authorAnatol Pomozov <anatol.pomozov@gmail.com>2012-09-12 23:11:55 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2013-02-22 23:31:32 -0500
commit39b652527457452f09b35044fb4f8b3b0eabafdf (patch)
treeacd8fda1d4e37c58c68fe0cfb9288d5d06e14441 /fs/anon_inodes.c
parent1afc99beaf0fca3767d9b67789a7ae91c4f7a9c9 (diff)
fs: Preserve error code in get_empty_filp(), part 2
Allocating a file structure in function get_empty_filp() might fail because of several reasons: - not enough memory for file structures - operation is not allowed - user is over its limit Currently the function returns NULL in all cases and we loose the exact reason of the error. All callers of get_empty_filp() assume that the function can fail with ENFILE only. Return error through pointer. Change all callers to preserve this error code. [AV: cleaned up a bit, carved the get_empty_filp() part out into a separate commit (things remaining here deal with alloc_file()), removed pipe(2) behaviour change] Signed-off-by: Anatol Pomozov <anatol.pomozov@gmail.com> Reviewed-by: "Theodore Ts'o" <tytso@mit.edu> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/anon_inodes.c')
-rw-r--r--fs/anon_inodes.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/fs/anon_inodes.c b/fs/anon_inodes.c
index 28d39fb84ae3..a14eb0c1cd8c 100644
--- a/fs/anon_inodes.c
+++ b/fs/anon_inodes.c
@@ -131,7 +131,6 @@ struct file *anon_inode_getfile(const char *name,
131 struct qstr this; 131 struct qstr this;
132 struct path path; 132 struct path path;
133 struct file *file; 133 struct file *file;
134 int error;
135 134
136 if (IS_ERR(anon_inode_inode)) 135 if (IS_ERR(anon_inode_inode))
137 return ERR_PTR(-ENODEV); 136 return ERR_PTR(-ENODEV);
@@ -143,7 +142,7 @@ struct file *anon_inode_getfile(const char *name,
143 * Link the inode to a directory entry by creating a unique name 142 * Link the inode to a directory entry by creating a unique name
144 * using the inode sequence number. 143 * using the inode sequence number.
145 */ 144 */
146 error = -ENOMEM; 145 file = ERR_PTR(-ENOMEM);
147 this.name = name; 146 this.name = name;
148 this.len = strlen(name); 147 this.len = strlen(name);
149 this.hash = 0; 148 this.hash = 0;
@@ -160,9 +159,8 @@ struct file *anon_inode_getfile(const char *name,
160 159
161 d_instantiate(path.dentry, anon_inode_inode); 160 d_instantiate(path.dentry, anon_inode_inode);
162 161
163 error = -ENFILE;
164 file = alloc_file(&path, OPEN_FMODE(flags), fops); 162 file = alloc_file(&path, OPEN_FMODE(flags), fops);
165 if (!file) 163 if (IS_ERR(file))
166 goto err_dput; 164 goto err_dput;
167 file->f_mapping = anon_inode_inode->i_mapping; 165 file->f_mapping = anon_inode_inode->i_mapping;
168 166
@@ -177,7 +175,7 @@ err_dput:
177 path_put(&path); 175 path_put(&path);
178err_module: 176err_module:
179 module_put(fops->owner); 177 module_put(fops->owner);
180 return ERR_PTR(error); 178 return file;
181} 179}
182EXPORT_SYMBOL_GPL(anon_inode_getfile); 180EXPORT_SYMBOL_GPL(anon_inode_getfile);
183 181