summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Lindqvist <anton@cvs.openbsd.org>2021-12-28 17:50:11 +0000
committerAnton Lindqvist <anton@cvs.openbsd.org>2021-12-28 17:50:11 +0000
commita593d638f76cad67efe5cebc13bac459056e2ce4 (patch)
treeeef18a4bb62868db8b3a84d6464077189d320198
parent266df027c95c1c3c523977d65de4d27fc5c6fe31 (diff)
The initial kd_lookup() in kcovopen() is redundant as kcov is a cloning
device. Turn it into an assertion instead to better state the expected semantics of D_CLONE. Prompted after a discussion with visa@
-rw-r--r--sys/dev/kcov.c18
1 files changed, 5 insertions, 13 deletions
diff --git a/sys/dev/kcov.c b/sys/dev/kcov.c
index 0a130fd0c25..5db7e764786 100644
--- a/sys/dev/kcov.c
+++ b/sys/dev/kcov.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kcov.c,v 1.42 2021/12/27 15:38:25 anton Exp $ */
+/* $OpenBSD: kcov.c,v 1.43 2021/12/28 17:50:10 anton Exp $ */
/*
* Copyright (c) 2018 Anton Lindqvist <anton@openbsd.org>
@@ -53,7 +53,7 @@
struct kcov_dev {
int kd_state; /* [M] */
int kd_mode; /* [M] */
- int kd_unit; /* [I] device minor */
+ int kd_unit; /* [I] D_CLONE unique device minor */
int kd_intr; /* [M] currently used in interrupt */
uintptr_t *kd_buf; /* [a] traced coverage */
size_t kd_nmemb; /* [I] */
@@ -290,21 +290,13 @@ kcovopen(dev_t dev, int flag, int mode, struct proc *p)
{
struct kcov_dev *kd;
- mtx_enter(&kcov_mtx);
-
- if (kd_lookup(minor(dev)) != NULL) {
- mtx_leave(&kcov_mtx);
- return (EBUSY);
- }
-
- if (kcov_cold)
- kcov_cold = 0;
-
- mtx_leave(&kcov_mtx);
kd = malloc(sizeof(*kd), M_SUBPROC, M_WAITOK | M_ZERO);
kd->kd_unit = minor(dev);
mtx_enter(&kcov_mtx);
+ KASSERT(kd_lookup(kd->kd_unit) == NULL);
TAILQ_INSERT_TAIL(&kd_list, kd, kd_entry);
+ if (kcov_cold)
+ kcov_cold = 0;
mtx_leave(&kcov_mtx);
return (0);
}