diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2014-11-20 14:18:09 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2014-12-11 16:27:57 -0500 |
commit | 893b7775a70e2e2050d5c3829996e906f7a3410c (patch) | |
tree | 8b333a05dfe37252612d49ef2c57f2464546da7a /fs/namei.c | |
parent | 5e53084d7734a1e1a64346f8480c0bb66c218764 (diff) | |
download | lwn-893b7775a70e2e2050d5c3829996e906f7a3410c.tar.gz lwn-893b7775a70e2e2050d5c3829996e906f7a3410c.zip |
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.c | 30 |
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, return -ECHILD; } +static void path_cleanup(struct nameidata *nd) +{ + if (nd->root.mnt && !(nd->flags & LOOKUP_ROOT)) { + path_put(&nd->root); + nd->root.mnt = NULL; + } + if (unlikely(nd->base)) + fput(nd->base); +} + static inline int lookup_last(struct nameidata *nd, struct path *path) { 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, } out: - if (nd->base) - fput(nd->base); - - if (nd->root.mnt && !(nd->flags & LOOKUP_ROOT)) { - path_put(&nd->root); - nd->root.mnt = NULL; - } + path_cleanup(nd); return err; } @@ -2349,12 +2353,7 @@ path_mountpoint(int dfd, const char *name, struct path *path, unsigned int flags put_link(&nd, &link, cookie); } out: - if (nd.base) - fput(nd.base); - - if (nd.root.mnt && !(nd.flags & LOOKUP_ROOT)) - path_put(&nd.root); - + path_cleanup(&nd); return err; } @@ -3252,10 +3251,7 @@ static struct file *path_openat(int dfd, struct filename *pathname, put_link(nd, &link, cookie); } out: - if (nd->root.mnt && !(nd->flags & LOOKUP_ROOT)) - path_put(&nd->root); - if (nd->base) - fput(nd->base); + path_cleanup(nd); if (!(opened & FILE_OPENED)) { BUG_ON(!error); put_filp(file); |