git: 747ee16a11ad - stable/15 - sound: Lock around mixer_set*() in mixer_init() for consistency

From: Christos Margiolis <christos_at_FreeBSD.org>
Date: Sun, 18 Oct 2026 08:13:31 UTC
The branch stable/15 has been updated by christos:

URL: https://cgit.FreeBSD.org/src/commit/?id=747ee16a11ade01a9d07d9dc6955c61dd0fcd258

commit 747ee16a11ade01a9d07d9dc6955c61dd0fcd258
Author:     Christos Margiolis <christos@FreeBSD.org>
AuthorDate: 2026-09-18 18:18:20 +0000
Commit:     Christos Margiolis <christos@FreeBSD.org>
CommitDate: 2026-10-18 08:10:49 +0000

    sound: Lock around mixer_set*() in mixer_init() for consistency
    
    Sponsored by:   The FreeBSD Foundation
    MFC after:      1 month
    Differential Revision:  https://reviews.freebsd.org/D59110
    
    (cherry picked from commit 47cf9dc7861371edcfdb85a38e2c240f430ccb28)
---
 sys/dev/sound/pcm/mixer.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/sys/dev/sound/pcm/mixer.c b/sys/dev/sound/pcm/mixer.c
index ff591cef799f..e3782e7ace04 100644
--- a/sys/dev/sound/pcm/mixer.c
+++ b/sys/dev/sound/pcm/mixer.c
@@ -557,6 +557,9 @@ mixer_init(device_t dev, kobj_class_t cls, void *devinfo)
 	if (m == NULL)
 		return (-1);
 
+	/* There is no need to lock here, but do it for consistency. */
+	mtx_lock(m->lock);
+
 	for (i = 0; i < SOUND_MIXER_NRDEVICES; i++) {
 		v = snd_mixerdefaults[i];
 
@@ -572,6 +575,8 @@ mixer_init(device_t dev, kobj_class_t cls, void *devinfo)
 
 	mixer_setrecsrc(m, 0); /* Set default input. */
 
+	mtx_unlock(m->lock);
+
 	snddev->mixer = m;
 
 	if (bootverbose) {