@@ -1873,7 +1873,7 @@ static int path_init(int dfd, const char *name, unsigned int flags,
18731873 } else {
18741874 path_get (& nd -> path );
18751875 }
1876- return 0 ;
1876+ goto done ;
18771877 }
18781878
18791879 nd -> root .mnt = NULL ;
@@ -1934,13 +1934,16 @@ static int path_init(int dfd, const char *name, unsigned int flags,
19341934
19351935 nd -> inode = nd -> path .dentry -> d_inode ;
19361936 if (!(flags & LOOKUP_RCU ))
1937- return 0 ;
1937+ goto done ;
19381938 if (likely (!read_seqcount_retry (& nd -> path .dentry -> d_seq , nd -> seq )))
1939- return 0 ;
1939+ goto done ;
19401940 if (!(nd -> flags & LOOKUP_ROOT ))
19411941 nd -> root .mnt = NULL ;
19421942 rcu_read_unlock ();
19431943 return - ECHILD ;
1944+ done :
1945+ current -> total_link_count = 0 ;
1946+ return link_path_walk (name , nd );
19441947}
19451948
19461949static void path_cleanup (struct nameidata * nd )
@@ -1984,13 +1987,6 @@ static int path_lookupat(int dfd, const char *name,
19841987 * be able to complete).
19851988 */
19861989 err = path_init (dfd , name , flags , nd );
1987-
1988- if (unlikely (err ))
1989- goto out ;
1990-
1991- current -> total_link_count = 0 ;
1992- err = link_path_walk (name , nd );
1993-
19941990 if (!err && !(flags & LOOKUP_PARENT )) {
19951991 err = lookup_last (nd , & path );
19961992 while (err > 0 ) {
@@ -2018,7 +2014,6 @@ static int path_lookupat(int dfd, const char *name,
20182014 }
20192015 }
20202016
2021- out :
20222017 path_cleanup (nd );
20232018 return err ;
20242019}
@@ -2333,11 +2328,6 @@ path_mountpoint(int dfd, const char *name, struct path *path, unsigned int flags
23332328 if (unlikely (err ))
23342329 goto out ;
23352330
2336- current -> total_link_count = 0 ;
2337- err = link_path_walk (name , & nd );
2338- if (err )
2339- goto out ;
2340-
23412331 err = mountpoint_last (& nd , path );
23422332 while (err > 0 ) {
23432333 void * cookie ;
@@ -3224,11 +3214,6 @@ static struct file *path_openat(int dfd, struct filename *pathname,
32243214 if (unlikely (error ))
32253215 goto out ;
32263216
3227- current -> total_link_count = 0 ;
3228- error = link_path_walk (pathname -> name , nd );
3229- if (unlikely (error ))
3230- goto out ;
3231-
32323217 error = do_last (nd , & path , file , op , & opened , pathname );
32333218 while (unlikely (error > 0 )) { /* trailing symlink */
32343219 struct path link = path ;
0 commit comments