Module Name:    src
Committed By:   riastradh
Date:           Fri Apr 21 18:09:38 UTC 2023

Modified Files:
        src/sys/dev/dkwedge: dk.c

Log Message:
dk(4): Restore assertions in dklastclose.

We only enter dklastclose if the wedge is open (sc->sc_dk.dk_openmask
!= 0), which can happen only if dkfirstopen has succeeded, in which
case we hold a dk_rawopens reference to the parent that prevents
anyone else from closing it.  Hence sc->sc_parent->dk_rawopens > 0.

On open, sc->sc_parent->dk_rawvp is set to nonnull, and it is only
reset to null on close.  Hence if the parent is still open, as it
must be here, sc->sc_parent->dk_rawvp must be nonnull.


To generate a diff of this commit:
cvs rdiff -u -r1.125 -r1.126 src/sys/dev/dkwedge/dk.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/dev/dkwedge/dk.c
diff -u src/sys/dev/dkwedge/dk.c:1.125 src/sys/dev/dkwedge/dk.c:1.126
--- src/sys/dev/dkwedge/dk.c:1.125	Thu Apr 13 08:30:40 2023
+++ src/sys/dev/dkwedge/dk.c	Fri Apr 21 18:09:38 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: dk.c,v 1.125 2023/04/13 08:30:40 riastradh Exp $	*/
+/*	$NetBSD: dk.c,v 1.126 2023/04/21 18:09:38 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2004, 2005, 2006, 2007 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dk.c,v 1.125 2023/04/13 08:30:40 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dk.c,v 1.126 2023/04/21 18:09:38 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_dkwedge.h"
@@ -1227,6 +1227,8 @@ dklastclose(struct dkwedge_softc *sc)
 
 	KASSERT(mutex_owned(&sc->sc_dk.dk_openlock));
 	KASSERT(mutex_owned(&sc->sc_parent->dk_rawlock));
+	KASSERT(sc->sc_parent->dk_rawopens > 0);
+	KASSERT(sc->sc_parent->dk_rawvp != NULL);
 
 	if (--sc->sc_parent->dk_rawopens == 0) {
 		struct vnode *const vp = sc->sc_parent->dk_rawvp;

Reply via email to