lkml.org 
[lkml]   [2018]   [Nov]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[PATCH 2/6] autofs - fix possible inode leak in autofs_fill_super()
From
Date
There is no check at all for a failure to allocate the root inode
in autofs_fill_super(), handle it.

Signed-off-by: Ian Kent <raven@themaw.net>
---
fs/autofs/inode.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/fs/autofs/inode.c b/fs/autofs/inode.c
index 846c052569dd..e5c06b5a7371 100644
--- a/fs/autofs/inode.c
+++ b/fs/autofs/inode.c
@@ -254,9 +254,13 @@ int autofs_fill_super(struct super_block *s, void *data, int silent)
goto fail_free;
}
root_inode = autofs_get_inode(s, S_IFDIR | 0755);
+ if (!root_inode) {
+ ret = -ENOMEM;
+ goto fail_ino;
+ }
root = d_make_root(root_inode);
if (!root)
- goto fail_ino;
+ goto fail_iput;
pipe = NULL;

root->d_fsdata = ino;
@@ -304,8 +308,8 @@ int autofs_fill_super(struct super_block *s, void *data, int silent)
root_inode->i_op = &autofs_dir_inode_operations;

pr_debug("pipe fd = %d, pgrp = %u\n", pipefd, pid_nr(sbi->oz_pgrp));
- pipe = fget(pipefd);

+ pipe = fget(pipefd);
if (!pipe) {
pr_err("could not open pipe file descriptor\n");
goto fail_put_pid;
@@ -334,6 +338,8 @@ int autofs_fill_super(struct super_block *s, void *data, int silent)
fail_dput:
dput(root);
goto fail_free;
+fail_iput:
+ iput(root_inode);
fail_ino:
autofs_free_ino(ino);
fail_free:
\
 
 \ /
  Last update: 2018-11-13 02:46    [W:0.059 / U:10.492 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site