svn commit: r310968 - stable/11/sys/kern

Mateusz Guzik mjg at FreeBSD.org
Sat Dec 31 12:58:28 UTC 2016


Author: mjg
Date: Sat Dec 31 12:58:26 2016
New Revision: 310968
URL: https://svnweb.freebsd.org/changeset/base/310968

Log:
  MFC r304927:
  
      vfs: provide a common exit point in namei for error cases
  
      This shortens the function, adds the SDT_PROBE use for error cases and
      consistenly unrefs rootdir last.

Modified:
  stable/11/sys/kern/vfs_lookup.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/kern/vfs_lookup.c
==============================================================================
--- stable/11/sys/kern/vfs_lookup.c	Sat Dec 31 12:52:58 2016	(r310967)
+++ stable/11/sys/kern/vfs_lookup.c	Sat Dec 31 12:58:26 2016	(r310968)
@@ -380,9 +380,7 @@ namei(struct nameidata *ndp)
 	if (error != 0) {
 		if (dp != NULL)
 			vrele(dp);
-		vrele(ndp->ni_rootdir);
-		namei_cleanup_cnp(cnp);
-		return (error);
+		goto out;
 	}
 	if ((ndp->ni_lcf & NI_LCF_STRICTRELATIVE) != 0 &&
 	    lookup_cap_dotdot != 0)
@@ -392,12 +390,8 @@ namei(struct nameidata *ndp)
 	for (;;) {
 		ndp->ni_startdir = dp;
 		error = lookup(ndp);
-		if (error != 0) {
-			vrele(ndp->ni_rootdir);
-			namei_cleanup_cnp(cnp);
-			SDT_PROBE2(vfs, namei, lookup, return, error, NULL);
-			return (error);
-		}
+		if (error != 0)
+			goto out;
 		/*
 		 * If not a symbolic link, we're done.
 		 */
@@ -471,18 +465,16 @@ namei(struct nameidata *ndp)
 		if (*(cnp->cn_nameptr) == '/') {
 			vrele(dp);
 			error = namei_handle_root(ndp, &dp);
-			if (error != 0) {
-				vrele(ndp->ni_rootdir);
-				namei_cleanup_cnp(cnp);
-				return (error);
-			}
+			if (error != 0)
+				goto out;
 		}
 	}
-	vrele(ndp->ni_rootdir);
-	namei_cleanup_cnp(cnp);
 	vput(ndp->ni_vp);
 	ndp->ni_vp = NULL;
 	vrele(ndp->ni_dvp);
+out:
+	vrele(ndp->ni_rootdir);
+	namei_cleanup_cnp(cnp);
 	nameicap_cleanup(ndp);
 	SDT_PROBE2(vfs, namei, lookup, return, error, NULL);
 	return (error);


More information about the svn-src-stable-11 mailing list