summaryrefslogtreecommitdiff
path: root/sys/dev/audio.c
diff options
context:
space:
mode:
authorVitaliy Makkoveev <mvs@cvs.openbsd.org>2024-08-20 07:44:37 +0000
committerVitaliy Makkoveev <mvs@cvs.openbsd.org>2024-08-20 07:44:37 +0000
commit8e6e36c5067aa2399c184ae4bcab8bc036c31d75 (patch)
tree80fa5165650e1964821e3016d3d80edbc3da89d1 /sys/dev/audio.c
parent8f592944cb7666c3994b0f325245bc73c0d70633 (diff)
Unlock sysctl_audio().
It is the only KERN_AUDIO_RECORD. `audio_record_enable' is atomically accessed integer. Reasonable from deraadt
Diffstat (limited to 'sys/dev/audio.c')
-rw-r--r--sys/dev/audio.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/sys/dev/audio.c b/sys/dev/audio.c
index d1847f1ef42..f06eead7760 100644
--- a/sys/dev/audio.c
+++ b/sys/dev/audio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: audio.c,v 1.207 2024/06/07 08:48:10 jsg Exp $ */
+/* $OpenBSD: audio.c,v 1.208 2024/08/20 07:44:36 mvs Exp $ */
/*
* Copyright (c) 2015 Alexandre Ratchov <alex@caoua.org>
*
@@ -27,11 +27,17 @@
#include <sys/malloc.h>
#include <sys/device.h>
#include <sys/audioio.h>
+#include <sys/atomic.h>
#include <dev/audio_if.h>
#include <dev/mulaw.h>
#include "audio.h"
#include "wskbd.h"
+/*
+ * Locks used to protect data:
+ * a atomic
+ */
+
#ifdef AUDIO_DEBUG
#define DPRINTF(...) \
do { \
@@ -225,7 +231,7 @@ struct mutex audio_lock = MUTEX_INITIALIZER(IPL_AUDIO);
* Global flag to control if audio recording is enabled when the
* mixerctl setting is record.enable=sysctl
*/
-int audio_record_enable = 0;
+int audio_record_enable = 0; /* [a] */
#ifdef AUDIO_DEBUG
/*
@@ -590,7 +596,7 @@ audio_rintr(void *addr)
sc->rec.pos += sc->rec.blksz;
if ((sc->record_enable == MIXER_RECORD_ENABLE_SYSCTL &&
- !audio_record_enable) ||
+ atomic_load_int(&audio_record_enable) == 0) ||
sc->record_enable == MIXER_RECORD_ENABLE_OFF) {
ptr = audio_buf_wgetblk(&sc->rec, &count);
audio_fill_sil(sc, ptr, sc->rec.blksz);