aboutsummaryrefslogtreecommitdiffstats
path: root/fs/namei.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2014-11-20 14:18:09 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2014-12-11 16:27:57 -0500
commit893b7775a70e2e2050d5c3829996e906f7a3410c (patch)
tree8b333a05dfe37252612d49ef2c57f2464546da7a /fs/namei.c
parent5e53084d7734a1e1a64346f8480c0bb66c218764 (diff)
fs/namei.c: new helper (path_cleanup())
All callers of path_init() proceed to do the identical cleanup when they are done with nameidata. Don't open-code it... Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/namei.c')
-rw-r--r--fs/namei.c30
1 files changed, 13 insertions, 17 deletions
diff --git a/fs/namei.c b/fs/namei.c
index e967f43e56ae..cfebb4fe675d 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1943,6 +1943,16 @@ static int path_init(int dfd, const char *name, unsigned int flags,
1943 return -ECHILD; 1943 return -ECHILD;
1944} 1944}
1945 1945
1946static void path_cleanup(struct nameidata *nd)
1947{
1948 if (nd->root.mnt && !(nd->flags & LOOKUP_ROOT)) {
1949 path_put(&nd->root);
1950 nd->root.mnt = NULL;
1951 }
1952 if (unlikely(nd->base))
1953 fput(nd->base);
1954}
1955
1946static inline int lookup_last(struct nameidata *nd, struct path *path) 1956static inline int lookup_last(struct nameidata *nd, struct path *path)
1947{ 1957{
1948 if (nd->last_type == LAST_NORM && nd->last.name[nd->last.len]) 1958 if (nd->last_type == LAST_NORM && nd->last.name[nd->last.len])
@@ -2009,13 +2019,7 @@ static int path_lookupat(int dfd, const char *name,
2009 } 2019 }
2010 2020
2011out: 2021out:
2012 if (nd->base) 2022 path_cleanup(nd);
2013 fput(nd->base);
2014
2015 if (nd->root.mnt && !(nd->flags & LOOKUP_ROOT)) {
2016 path_put(&nd->root);
2017 nd->root.mnt = NULL;
2018 }
2019 return err; 2023 return err;
2020} 2024}
2021 2025
@@ -2349,12 +2353,7 @@ path_mountpoint(int dfd, const char *name, struct path *path, unsigned int flags
2349 put_link(&nd, &link, cookie); 2353 put_link(&nd, &link, cookie);
2350 } 2354 }
2351out: 2355out:
2352 if (nd.base) 2356 path_cleanup(&nd);
2353 fput(nd.base);
2354
2355 if (nd.root.mnt && !(nd.flags & LOOKUP_ROOT))
2356 path_put(&nd.root);
2357
2358 return err; 2357 return err;
2359} 2358}
2360 2359
@@ -3252,10 +3251,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
3252 put_link(nd, &link, cookie); 3251 put_link(nd, &link, cookie);
3253 } 3252 }
3254out: 3253out:
3255 if (nd->root.mnt && !(nd->flags & LOOKUP_ROOT)) 3254 path_cleanup(nd);
3256 path_put(&nd->root);
3257 if (nd->base)
3258 fput(nd->base);
3259 if (!(opened & FILE_OPENED)) { 3255 if (!(opened & FILE_OPENED)) {
3260 BUG_ON(!error); 3256 BUG_ON(!error);
3261 put_filp(file); 3257 put_filp(file);