Module Name: src Committed By: martin Date: Fri Apr 24 17:42:53 UTC 2020
Modified Files: src/sys/dev/dkwedge [netbsd-9]: dk.c Log Message: Pull up following revision(s) (requested by maya in ticket #850): sys/dev/dkwedge/dk.c: revision 1.98 Update sc->sc_parent->dk_rawvp while the lock named dk_rawlock held to prevent a race condition Fixes PR kern/55026 OKed by mlelstv@, thanks To generate a diff of this commit: cvs rdiff -u -r1.97.8.2 -r1.97.8.3 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.97.8.2 src/sys/dev/dkwedge/dk.c:1.97.8.3 --- src/sys/dev/dkwedge/dk.c:1.97.8.2 Mon Apr 6 14:53:33 2020 +++ src/sys/dev/dkwedge/dk.c Fri Apr 24 17:42:53 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: dk.c,v 1.97.8.2 2020/04/06 14:53:33 martin Exp $ */ +/* $NetBSD: dk.c,v 1.97.8.3 2020/04/24 17:42:53 martin 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.97.8.2 2020/04/06 14:53:33 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dk.c,v 1.97.8.3 2020/04/24 17:42:53 martin Exp $"); #ifdef _KERNEL_OPT #include "opt_dkwedge.h" @@ -1152,21 +1152,23 @@ dkopen(dev_t dev, int flags, int fmt, st static int dklastclose(struct dkwedge_softc *sc) { - int error = 0, doclose; + struct vnode *vp; + int error = 0; - doclose = 0; + vp = NULL; if (sc->sc_parent->dk_rawopens > 0) { - if (--sc->sc_parent->dk_rawopens == 0) - doclose = 1; + if (--sc->sc_parent->dk_rawopens == 0) { + KASSERT(sc->sc_parent->dk_rawvp != NULL); + vp = sc->sc_parent->dk_rawvp; + sc->sc_parent->dk_rawvp = NULL; + } } mutex_exit(&sc->sc_parent->dk_rawlock); mutex_exit(&sc->sc_dk.dk_openlock); - if (doclose) { - KASSERT(sc->sc_parent->dk_rawvp != NULL); - dk_close_parent(sc->sc_parent->dk_rawvp, FREAD | FWRITE); - sc->sc_parent->dk_rawvp = NULL; + if (vp) { + dk_close_parent(vp, FREAD | FWRITE); } return error;