diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2014-10-11 23:05:52 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2014-10-12 17:09:04 -0400 |
commit | 115cbfdc609702a131c51281864c08f5d27b459a (patch) | |
tree | 14f486537d5897e9df9fdae73dd2844c5f181af2 /fs/namei.c | |
parent | 24dff96a37a2ca319e75a74d3929b2de22447ca6 (diff) |
let path_init() failures treated the same way as subsequent link_path_walk()
As it is, path_lookupat() and path_mounpoint() might end up leaking struct file
reference in some cases.
Spotted-by: Eric Biggers <ebiggers3@gmail.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/namei.c')
-rw-r--r-- | fs/namei.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/fs/namei.c b/fs/namei.c index d20d579a022e..0f64aa412617 100644 --- a/fs/namei.c +++ b/fs/namei.c | |||
@@ -1950,7 +1950,7 @@ static int path_lookupat(int dfd, const char *name, | |||
1950 | err = path_init(dfd, name, flags | LOOKUP_PARENT, nd, &base); | 1950 | err = path_init(dfd, name, flags | LOOKUP_PARENT, nd, &base); |
1951 | 1951 | ||
1952 | if (unlikely(err)) | 1952 | if (unlikely(err)) |
1953 | return err; | 1953 | goto out; |
1954 | 1954 | ||
1955 | current->total_link_count = 0; | 1955 | current->total_link_count = 0; |
1956 | err = link_path_walk(name, nd); | 1956 | err = link_path_walk(name, nd); |
@@ -1982,6 +1982,7 @@ static int path_lookupat(int dfd, const char *name, | |||
1982 | } | 1982 | } |
1983 | } | 1983 | } |
1984 | 1984 | ||
1985 | out: | ||
1985 | if (base) | 1986 | if (base) |
1986 | fput(base); | 1987 | fput(base); |
1987 | 1988 | ||
@@ -2301,7 +2302,7 @@ path_mountpoint(int dfd, const char *name, struct path *path, unsigned int flags | |||
2301 | 2302 | ||
2302 | err = path_init(dfd, name, flags | LOOKUP_PARENT, &nd, &base); | 2303 | err = path_init(dfd, name, flags | LOOKUP_PARENT, &nd, &base); |
2303 | if (unlikely(err)) | 2304 | if (unlikely(err)) |
2304 | return err; | 2305 | goto out; |
2305 | 2306 | ||
2306 | current->total_link_count = 0; | 2307 | current->total_link_count = 0; |
2307 | err = link_path_walk(name, &nd); | 2308 | err = link_path_walk(name, &nd); |