summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorriastradh <riastradh@NetBSD.org>2023-05-22 14:59:42 +0000
committerriastradh <riastradh@NetBSD.org>2023-05-22 14:59:42 +0000
commit870887472d22cb56bb72ad160083dbf65bf5320c (patch)
tree21105333b780d9f9bd88bd83bccca7b77a6e2aab /sys/dev
parent76031411ad161566edd0a91f01ee9860b5283cb2 (diff)
dk(4): Strengthen dkopen preconditions.
This cannot be called before dkwedge_attach for the same unit returns, so sc->sc_dev is guaranteed to be set to a nonnull device_t and the state is guaranteed not to be larval. And this cannot be called concurrently with dkwedge_detach, or after dkwedge_detach does vdevgone until another wedge with the same number is attached (which can't happen until dkwedge_detach completes), so the state is guaranteed not to be dying or dead. Hence sc->sc_dev != NULL and sc->sc_state == DKW_STATE_RUNNING.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/dkwedge/dk.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/sys/dev/dkwedge/dk.c b/sys/dev/dkwedge/dk.c
index 8920f51211f..68b396b4b6f 100644
--- a/sys/dev/dkwedge/dk.c
+++ b/sys/dev/dkwedge/dk.c
@@ -1,4 +1,4 @@
-/* $NetBSD: dk.c,v 1.166 2023/05/22 14:59:34 riastradh Exp $ */
+/* $NetBSD: dk.c,v 1.167 2023/05/22 14:59:42 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.166 2023/05/22 14:59:34 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dk.c,v 1.167 2023/05/22 14:59:42 riastradh Exp $");
#ifdef _KERNEL_OPT
#include "opt_dkwedge.h"
@@ -1277,8 +1277,8 @@ dkopen(dev_t dev, int flags, int fmt, struct lwp *l)
if (sc == NULL)
return ENXIO;
- if (sc->sc_state != DKW_STATE_RUNNING)
- return ENXIO;
+ KASSERT(sc->sc_dev != NULL);
+ KASSERT(sc->sc_state == DKW_STATE_RUNNING);
/*
* We go through a complicated little dance to only open the parent