Module Name:    src
Committed By:   dholland
Date:           Mon Apr 11 02:17:54 UTC 2011

Modified Files:
        src/sys/kern: vfs_lookup.c

Log Message:
description:
Make sure namei_oneroot leaves ni_dvp and ni_vp NULL on error.


To generate a diff of this commit:
cvs rdiff -u -r1.163 -r1.164 src/sys/kern/vfs_lookup.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/kern/vfs_lookup.c
diff -u src/sys/kern/vfs_lookup.c:1.163 src/sys/kern/vfs_lookup.c:1.164
--- src/sys/kern/vfs_lookup.c:1.163	Mon Apr 11 02:17:41 2011
+++ src/sys/kern/vfs_lookup.c	Mon Apr 11 02:17:54 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_lookup.c,v 1.163 2011/04/11 02:17:41 dholland Exp $	*/
+/*	$NetBSD: vfs_lookup.c,v 1.164 2011/04/11 02:17:54 dholland Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_lookup.c,v 1.163 2011/04/11 02:17:41 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_lookup.c,v 1.164 2011/04/11 02:17:54 dholland Exp $");
 
 #include "opt_magiclinks.h"
 
@@ -592,7 +592,6 @@
 	 * POSIX.1 requirement: "" is not a valid file name.
 	 */
 	if (ndp->ni_pathlen == 1) {
-		ndp->ni_vp = NULL;
 		return ENOENT;
 	}
 
@@ -1034,6 +1033,8 @@
 
 	error = namei_start(state, forcecwd, &searchdir);
 	if (error) {
+		ndp->ni_dvp = NULL;
+		ndp->ni_vp = NULL;
 		return error;
 	}
 
@@ -1057,6 +1058,8 @@
 		 */
 		if (searchdir->v_mount == NULL) {
 			vput(searchdir);
+			ndp->ni_dvp = NULL;
+			ndp->ni_vp = NULL;
 			return (ENOENT);
 		}
 
@@ -1374,8 +1377,8 @@
 
 	if (error) {
 		/* make sure no stray refs leak out */
-		ndp->ni_dvp = NULL;
-		ndp->ni_vp = NULL;
+		KASSERT(ndp->ni_dvp == NULL);
+		KASSERT(ndp->ni_vp == NULL);
 	}
 
 	return error;
@@ -1410,8 +1413,8 @@
 
 	if (error) {
 		/* make sure no stray refs leak out */
-		ndp->ni_dvp = NULL;
-		ndp->ni_vp = NULL;
+		KASSERT(ndp->ni_dvp == NULL);
+		KASSERT(ndp->ni_vp == NULL);
 	}
 
 	return error;

Reply via email to