aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRui Xiang <rui.xiang@huawei.com>2014-01-23 18:54:59 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2014-01-23 19:36:59 -0500
commitda29b7543957c6e967066f1ee18fab2feb0eeeb3 (patch)
tree677ef5f4b80cc040d69a062aafaa573ab4b85304
parentfbff08706d12fcdb160604c4ba790df6707c32cb (diff)
autofs: fix the return value of autofs4_fill_super
While kzallocing sbi/ino fails, it should return -ENOMEM. And it should return the err value from autofs_prepare_pipe. Signed-off-by: Rui Xiang <rui.xiang@huawei.com> Signed-off-by: Ian Kent <raven@themaw.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--fs/autofs4/inode.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/fs/autofs4/inode.c b/fs/autofs4/inode.c
index a3de082db620..d7bd395ab586 100644
--- a/fs/autofs4/inode.c
+++ b/fs/autofs4/inode.c
@@ -212,10 +212,11 @@ int autofs4_fill_super(struct super_block *s, void *data, int silent)
212 struct autofs_info *ino; 212 struct autofs_info *ino;
213 int pgrp; 213 int pgrp;
214 bool pgrp_set = false; 214 bool pgrp_set = false;
215 int ret = -EINVAL;
215 216
216 sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); 217 sbi = kzalloc(sizeof(*sbi), GFP_KERNEL);
217 if (!sbi) 218 if (!sbi)
218 goto fail_unlock; 219 return -ENOMEM;
219 DPRINTK("starting up, sbi = %p",sbi); 220 DPRINTK("starting up, sbi = %p",sbi);
220 221
221 s->s_fs_info = sbi; 222 s->s_fs_info = sbi;
@@ -249,8 +250,10 @@ int autofs4_fill_super(struct super_block *s, void *data, int silent)
249 * Get the root inode and dentry, but defer checking for errors. 250 * Get the root inode and dentry, but defer checking for errors.
250 */ 251 */
251 ino = autofs4_new_ino(sbi); 252 ino = autofs4_new_ino(sbi);
252 if (!ino) 253 if (!ino) {
254 ret = -ENOMEM;
253 goto fail_free; 255 goto fail_free;
256 }
254 root_inode = autofs4_get_inode(s, S_IFDIR | 0755); 257 root_inode = autofs4_get_inode(s, S_IFDIR | 0755);
255 root = d_make_root(root_inode); 258 root = d_make_root(root_inode);
256 if (!root) 259 if (!root)
@@ -308,7 +311,8 @@ int autofs4_fill_super(struct super_block *s, void *data, int silent)
308 printk("autofs: could not open pipe file descriptor\n"); 311 printk("autofs: could not open pipe file descriptor\n");
309 goto fail_dput; 312 goto fail_dput;
310 } 313 }
311 if (autofs_prepare_pipe(pipe) < 0) 314 ret = autofs_prepare_pipe(pipe);
315 if (ret < 0)
312 goto fail_fput; 316 goto fail_fput;
313 sbi->pipe = pipe; 317 sbi->pipe = pipe;
314 sbi->pipefd = pipefd; 318 sbi->pipefd = pipefd;
@@ -336,8 +340,7 @@ fail_free:
336 put_pid(sbi->oz_pgrp); 340 put_pid(sbi->oz_pgrp);
337 kfree(sbi); 341 kfree(sbi);
338 s->s_fs_info = NULL; 342 s->s_fs_info = NULL;
339fail_unlock: 343 return ret;
340 return -EINVAL;
341} 344}
342 345
343struct inode *autofs4_get_inode(struct super_block *sb, umode_t mode) 346struct inode *autofs4_get_inode(struct super_block *sb, umode_t mode)