aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/namei.c15
-rw-r--r--include/linux/namei.h1
2 files changed, 7 insertions, 9 deletions
diff --git a/fs/namei.c b/fs/namei.c
index 85f6e39b4034..a260a306daf5 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1498,7 +1498,8 @@ lookup_parent:
1498 return err; 1498 return err;
1499} 1499}
1500 1500
1501static int path_init(int dfd, const char *name, unsigned int flags, struct nameidata *nd) 1501static int path_init(int dfd, const char *name, unsigned int flags,
1502 struct nameidata *nd, struct file **fp)
1502{ 1503{
1503 int retval = 0; 1504 int retval = 0;
1504 int fput_needed; 1505 int fput_needed;
@@ -1508,7 +1509,6 @@ static int path_init(int dfd, const char *name, unsigned int flags, struct namei
1508 nd->flags = flags | LOOKUP_JUMPED; 1509 nd->flags = flags | LOOKUP_JUMPED;
1509 nd->depth = 0; 1510 nd->depth = 0;
1510 nd->root.mnt = NULL; 1511 nd->root.mnt = NULL;
1511 nd->file = NULL;
1512 1512
1513 if (*name=='/') { 1513 if (*name=='/') {
1514 if (flags & LOOKUP_RCU) { 1514 if (flags & LOOKUP_RCU) {
@@ -1557,7 +1557,7 @@ static int path_init(int dfd, const char *name, unsigned int flags, struct namei
1557 nd->path = file->f_path; 1557 nd->path = file->f_path;
1558 if (flags & LOOKUP_RCU) { 1558 if (flags & LOOKUP_RCU) {
1559 if (fput_needed) 1559 if (fput_needed)
1560 nd->file = file; 1560 *fp = file;
1561 nd->seq = __read_seqcount_begin(&nd->path.dentry->d_seq); 1561 nd->seq = __read_seqcount_begin(&nd->path.dentry->d_seq);
1562 br_read_lock(vfsmount_lock); 1562 br_read_lock(vfsmount_lock);
1563 rcu_read_lock(); 1563 rcu_read_lock();
@@ -1580,6 +1580,7 @@ out_fail:
1580static int path_lookupat(int dfd, const char *name, 1580static int path_lookupat(int dfd, const char *name,
1581 unsigned int flags, struct nameidata *nd) 1581 unsigned int flags, struct nameidata *nd)
1582{ 1582{
1583 struct file *base = NULL;
1583 int retval; 1584 int retval;
1584 1585
1585 /* 1586 /*
@@ -1596,7 +1597,7 @@ static int path_lookupat(int dfd, const char *name,
1596 * be handled by restarting a traditional ref-walk (which will always 1597 * be handled by restarting a traditional ref-walk (which will always
1597 * be able to complete). 1598 * be able to complete).
1598 */ 1599 */
1599 retval = path_init(dfd, name, flags, nd); 1600 retval = path_init(dfd, name, flags, nd, &base);
1600 1601
1601 if (unlikely(retval)) 1602 if (unlikely(retval))
1602 return retval; 1603 return retval;
@@ -1614,10 +1615,8 @@ static int path_lookupat(int dfd, const char *name,
1614 if (!retval) 1615 if (!retval)
1615 retval = handle_reval_path(nd); 1616 retval = handle_reval_path(nd);
1616 1617
1617 if (nd->file) { 1618 if (base)
1618 fput(nd->file); 1619 fput(base);
1619 nd->file = NULL;
1620 }
1621 1620
1622 if (nd->root.mnt) { 1621 if (nd->root.mnt) {
1623 path_put(&nd->root); 1622 path_put(&nd->root);
diff --git a/include/linux/namei.h b/include/linux/namei.h
index 265378a707bd..72ffd62ac736 100644
--- a/include/linux/namei.h
+++ b/include/linux/namei.h
@@ -19,7 +19,6 @@ struct nameidata {
19 struct path path; 19 struct path path;
20 struct qstr last; 20 struct qstr last;
21 struct path root; 21 struct path root;
22 struct file *file;
23 struct inode *inode; /* path.dentry.d_inode */ 22 struct inode *inode; /* path.dentry.d_inode */
24 unsigned int flags; 23 unsigned int flags;
25 unsigned seq; 24 unsigned seq;