aboutsummaryrefslogtreecommitdiffstats
path: root/fs/namei.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/namei.c')
-rw-r--r--fs/namei.c56
1 files changed, 31 insertions, 25 deletions
diff --git a/fs/namei.c b/fs/namei.c
index c9b05a71c39..b0df7ea733d 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -362,11 +362,18 @@ int deny_write_access(struct file * file)
362 return 0; 362 return 0;
363} 363}
364 364
365void path_release(struct nameidata *nd) 365/**
366 * path_put - put a reference to a path
367 * @path: path to put the reference to
368 *
369 * Given a path decrement the reference count to the dentry and the vfsmount.
370 */
371void path_put(struct path *path)
366{ 372{
367 dput(nd->path.dentry); 373 dput(path->dentry);
368 mntput(nd->path.mnt); 374 mntput(path->mnt);
369} 375}
376EXPORT_SYMBOL(path_put);
370 377
371/** 378/**
372 * release_open_intent - free up open intent resources 379 * release_open_intent - free up open intent resources
@@ -551,7 +558,7 @@ static __always_inline int __vfs_follow_link(struct nameidata *nd, const char *l
551 goto fail; 558 goto fail;
552 559
553 if (*link == '/') { 560 if (*link == '/') {
554 path_release(nd); 561 path_put(&nd->path);
555 if (!walk_init_root(link, nd)) 562 if (!walk_init_root(link, nd))
556 /* weird __emul_prefix() stuff did it */ 563 /* weird __emul_prefix() stuff did it */
557 goto out; 564 goto out;
@@ -567,18 +574,18 @@ out:
567 */ 574 */
568 name = __getname(); 575 name = __getname();
569 if (unlikely(!name)) { 576 if (unlikely(!name)) {
570 path_release(nd); 577 path_put(&nd->path);
571 return -ENOMEM; 578 return -ENOMEM;
572 } 579 }
573 strcpy(name, nd->last.name); 580 strcpy(name, nd->last.name);
574 nd->last.name = name; 581 nd->last.name = name;
575 return 0; 582 return 0;
576fail: 583fail:
577 path_release(nd); 584 path_put(&nd->path);
578 return PTR_ERR(link); 585 return PTR_ERR(link);
579} 586}
580 587
581static inline void dput_path(struct path *path, struct nameidata *nd) 588static void path_put_conditional(struct path *path, struct nameidata *nd)
582{ 589{
583 dput(path->dentry); 590 dput(path->dentry);
584 if (path->mnt != nd->path.mnt) 591 if (path->mnt != nd->path.mnt)
@@ -651,8 +658,8 @@ static inline int do_follow_link(struct path *path, struct nameidata *nd)
651 nd->depth--; 658 nd->depth--;
652 return err; 659 return err;
653loop: 660loop:
654 dput_path(path, nd); 661 path_put_conditional(path, nd);
655 path_release(nd); 662 path_put(&nd->path);
656 return err; 663 return err;
657} 664}
658 665
@@ -993,10 +1000,10 @@ return_reval:
993return_base: 1000return_base:
994 return 0; 1001 return 0;
995out_dput: 1002out_dput:
996 dput_path(&next, nd); 1003 path_put_conditional(&next, nd);
997 break; 1004 break;
998 } 1005 }
999 path_release(nd); 1006 path_put(&nd->path);
1000return_err: 1007return_err:
1001 return err; 1008 return err;
1002} 1009}
@@ -1070,7 +1077,7 @@ static int __emul_lookup_dentry(const char *name, struct nameidata *nd)
1070 mntput(old_mnt); 1077 mntput(old_mnt);
1071 return 1; 1078 return 1;
1072 } 1079 }
1073 path_release(nd); 1080 path_put(&nd->path);
1074 } 1081 }
1075 nd->path.dentry = old_dentry; 1082 nd->path.dentry = old_dentry;
1076 nd->path.mnt = old_mnt; 1083 nd->path.mnt = old_mnt;
@@ -1230,7 +1237,7 @@ static int __path_lookup_intent_open(int dfd, const char *name,
1230 if (IS_ERR(nd->intent.open.file)) { 1237 if (IS_ERR(nd->intent.open.file)) {
1231 if (err == 0) { 1238 if (err == 0) {
1232 err = PTR_ERR(nd->intent.open.file); 1239 err = PTR_ERR(nd->intent.open.file);
1233 path_release(nd); 1240 path_put(&nd->path);
1234 } 1241 }
1235 } else if (err != 0) 1242 } else if (err != 0)
1236 release_open_intent(nd); 1243 release_open_intent(nd);
@@ -1806,11 +1813,11 @@ ok:
1806 return 0; 1813 return 0;
1807 1814
1808exit_dput: 1815exit_dput:
1809 dput_path(&path, nd); 1816 path_put_conditional(&path, nd);
1810exit: 1817exit:
1811 if (!IS_ERR(nd->intent.open.file)) 1818 if (!IS_ERR(nd->intent.open.file))
1812 release_open_intent(nd); 1819 release_open_intent(nd);
1813 path_release(nd); 1820 path_put(&nd->path);
1814 return error; 1821 return error;
1815 1822
1816do_link: 1823do_link:
@@ -1979,7 +1986,7 @@ asmlinkage long sys_mknodat(int dfd, const char __user *filename, int mode,
1979 dput(dentry); 1986 dput(dentry);
1980 } 1987 }
1981 mutex_unlock(&nd.path.dentry->d_inode->i_mutex); 1988 mutex_unlock(&nd.path.dentry->d_inode->i_mutex);
1982 path_release(&nd); 1989 path_put(&nd.path);
1983out: 1990out:
1984 putname(tmp); 1991 putname(tmp);
1985 1992
@@ -2039,7 +2046,7 @@ asmlinkage long sys_mkdirat(int dfd, const char __user *pathname, int mode)
2039 dput(dentry); 2046 dput(dentry);
2040out_unlock: 2047out_unlock:
2041 mutex_unlock(&nd.path.dentry->d_inode->i_mutex); 2048 mutex_unlock(&nd.path.dentry->d_inode->i_mutex);
2042 path_release(&nd); 2049 path_put(&nd.path);
2043out: 2050out:
2044 putname(tmp); 2051 putname(tmp);
2045out_err: 2052out_err:
@@ -2147,7 +2154,7 @@ static long do_rmdir(int dfd, const char __user *pathname)
2147exit2: 2154exit2:
2148 mutex_unlock(&nd.path.dentry->d_inode->i_mutex); 2155 mutex_unlock(&nd.path.dentry->d_inode->i_mutex);
2149exit1: 2156exit1:
2150 path_release(&nd); 2157 path_put(&nd.path);
2151exit: 2158exit:
2152 putname(name); 2159 putname(name);
2153 return error; 2160 return error;
@@ -2231,7 +2238,7 @@ static long do_unlinkat(int dfd, const char __user *pathname)
2231 if (inode) 2238 if (inode)
2232 iput(inode); /* truncate the inode here */ 2239 iput(inode); /* truncate the inode here */
2233exit1: 2240exit1:
2234 path_release(&nd); 2241 path_put(&nd.path);
2235exit: 2242exit:
2236 putname(name); 2243 putname(name);
2237 return error; 2244 return error;
@@ -2308,7 +2315,7 @@ asmlinkage long sys_symlinkat(const char __user *oldname,
2308 dput(dentry); 2315 dput(dentry);
2309out_unlock: 2316out_unlock:
2310 mutex_unlock(&nd.path.dentry->d_inode->i_mutex); 2317 mutex_unlock(&nd.path.dentry->d_inode->i_mutex);
2311 path_release(&nd); 2318 path_put(&nd.path);
2312out: 2319out:
2313 putname(to); 2320 putname(to);
2314out_putname: 2321out_putname:
@@ -2404,9 +2411,9 @@ asmlinkage long sys_linkat(int olddfd, const char __user *oldname,
2404out_unlock: 2411out_unlock:
2405 mutex_unlock(&nd.path.dentry->d_inode->i_mutex); 2412 mutex_unlock(&nd.path.dentry->d_inode->i_mutex);
2406out_release: 2413out_release:
2407 path_release(&nd); 2414 path_put(&nd.path);
2408out: 2415out:
2409 path_release(&old_nd); 2416 path_put(&old_nd.path);
2410exit: 2417exit:
2411 putname(to); 2418 putname(to);
2412 2419
@@ -2634,9 +2641,9 @@ exit4:
2634exit3: 2641exit3:
2635 unlock_rename(new_dir, old_dir); 2642 unlock_rename(new_dir, old_dir);
2636exit2: 2643exit2:
2637 path_release(&newnd); 2644 path_put(&newnd.path);
2638exit1: 2645exit1:
2639 path_release(&oldnd); 2646 path_put(&oldnd.path);
2640exit: 2647exit:
2641 return error; 2648 return error;
2642} 2649}
@@ -2810,7 +2817,6 @@ EXPORT_SYMBOL(page_symlink);
2810EXPORT_SYMBOL(page_symlink_inode_operations); 2817EXPORT_SYMBOL(page_symlink_inode_operations);
2811EXPORT_SYMBOL(path_lookup); 2818EXPORT_SYMBOL(path_lookup);
2812EXPORT_SYMBOL(vfs_path_lookup); 2819EXPORT_SYMBOL(vfs_path_lookup);
2813EXPORT_SYMBOL(path_release);
2814EXPORT_SYMBOL(permission); 2820EXPORT_SYMBOL(permission);
2815EXPORT_SYMBOL(vfs_permission); 2821EXPORT_SYMBOL(vfs_permission);
2816EXPORT_SYMBOL(file_permission); 2822EXPORT_SYMBOL(file_permission);