Module Name:    src
Committed By:   riastradh
Date:           Thu Mar 24 12:59:56 UTC 2022

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

Log Message:
vfs(9): Add missing vnode lock around VOP_CLOSE in vfs_mountroot.

Maybe vnode_if.c should be taught to KASSERT the vnode lock now that
locks always work.


To generate a diff of this commit:
cvs rdiff -u -r1.90 -r1.91 src/sys/kern/vfs_mount.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_mount.c
diff -u src/sys/kern/vfs_mount.c:1.90 src/sys/kern/vfs_mount.c:1.91
--- src/sys/kern/vfs_mount.c:1.90	Sat Mar 19 13:50:28 2022
+++ src/sys/kern/vfs_mount.c	Thu Mar 24 12:59:56 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_mount.c,v 1.90 2022/03/19 13:50:28 hannken Exp $	*/
+/*	$NetBSD: vfs_mount.c,v 1.91 2022/03/24 12:59:56 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 1997-2020 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.90 2022/03/19 13:50:28 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.91 2022/03/24 12:59:56 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -1246,7 +1246,9 @@ vfs_mountroot(void)
 
 done:
 	if (error && device_class(root_device) == DV_DISK) {
+		vn_lock(rootvp, LK_EXCLUSIVE | LK_RETRY);
 		VOP_CLOSE(rootvp, FREAD, FSCRED);
+		VOP_UNLOCK(rootvp);
 		vrele(rootvp);
 	}
 	if (error == 0) {

Reply via email to