@@ -779,7 +779,8 @@ static void path_put_conditional(struct path *path, struct nameidata *nd)
779779 mntput (path -> mnt );
780780}
781781
782- static inline void path_to_nameidata (struct path * path , struct nameidata * nd )
782+ static inline void path_to_nameidata (const struct path * path ,
783+ struct nameidata * nd )
783784{
784785 if (!(nd -> flags & LOOKUP_RCU )) {
785786 dput (nd -> path .dentry );
@@ -791,20 +792,20 @@ static inline void path_to_nameidata(struct path *path, struct nameidata *nd)
791792}
792793
793794static __always_inline int
794- __do_follow_link (struct path * path , struct nameidata * nd , void * * p )
795+ __do_follow_link (const struct path * link , struct nameidata * nd , void * * p )
795796{
796797 int error ;
797- struct dentry * dentry = path -> dentry ;
798+ struct dentry * dentry = link -> dentry ;
798799
799- touch_atime (path -> mnt , dentry );
800+ touch_atime (link -> mnt , dentry );
800801 nd_set_link (nd , NULL );
801802
802- if (path -> mnt != nd -> path .mnt ) {
803- path_to_nameidata (path , nd );
803+ if (link -> mnt != nd -> path .mnt ) {
804+ path_to_nameidata (link , nd );
804805 nd -> inode = nd -> path .dentry -> d_inode ;
805806 dget (dentry );
806807 }
807- mntget (path -> mnt );
808+ mntget (link -> mnt );
808809
809810 nd -> last_type = LAST_BIND ;
810811 * p = dentry -> d_inode -> i_op -> follow_link (dentry , nd );
@@ -2348,11 +2349,12 @@ struct file *do_filp_open(int dfd, const char *pathname,
23482349 nd .flags = flags ;
23492350 filp = do_last (& nd , & path , open_flag , acc_mode , mode , pathname );
23502351 while (unlikely (!filp )) { /* trailing symlink */
2351- struct path holder ;
2352+ struct path link = path ;
2353+ struct inode * linki = link .dentry -> d_inode ;
23522354 void * cookie ;
23532355 error = - ELOOP ;
23542356 /* S_ISDIR part is a temporary automount kludge */
2355- if (!(nd .flags & LOOKUP_FOLLOW ) && !S_ISDIR (nd . inode -> i_mode ))
2357+ if (!(nd .flags & LOOKUP_FOLLOW ) && !S_ISDIR (linki -> i_mode ))
23562358 goto exit_dput ;
23572359 if (count ++ == 32 )
23582360 goto exit_dput ;
@@ -2368,23 +2370,22 @@ struct file *do_filp_open(int dfd, const char *pathname,
23682370 * just set LAST_BIND.
23692371 */
23702372 nd .flags |= LOOKUP_PARENT ;
2371- error = security_inode_follow_link (path .dentry , & nd );
2373+ error = security_inode_follow_link (link .dentry , & nd );
23722374 if (error )
23732375 goto exit_dput ;
2374- error = __do_follow_link (& path , & nd , & cookie );
2376+ error = __do_follow_link (& link , & nd , & cookie );
23752377 if (unlikely (error )) {
2376- if (!IS_ERR (cookie ) && nd . inode -> i_op -> put_link )
2377- nd . inode -> i_op -> put_link (path .dentry , & nd , cookie );
2378+ if (!IS_ERR (cookie ) && linki -> i_op -> put_link )
2379+ linki -> i_op -> put_link (link .dentry , & nd , cookie );
23782380 /* nd.path had been dropped */
2379- nd .path = path ;
2381+ nd .path = link ;
23802382 goto out_path ;
23812383 }
2382- holder = path ;
23832384 nd .flags &= ~LOOKUP_PARENT ;
23842385 filp = do_last (& nd , & path , open_flag , acc_mode , mode , pathname );
2385- if (nd . inode -> i_op -> put_link )
2386- nd . inode -> i_op -> put_link (holder .dentry , & nd , cookie );
2387- path_put (& holder );
2386+ if (linki -> i_op -> put_link )
2387+ linki -> i_op -> put_link (link .dentry , & nd , cookie );
2388+ path_put (& link );
23882389 }
23892390out :
23902391 if (nd .root .mnt )
0 commit comments