git: dabd959b1759 - main - snd_uaudio: Do not touch mixer_lock when there is no mixer
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 14 Nov 2026 09:49:41 UTC
The branch main has been updated by christos:
URL: https://cgit.FreeBSD.org/src/commit/?id=dabd959b17597ad790327020a667ced9a05d7499
commit dabd959b17597ad790327020a667ced9a05d7499
Author: Christos Margiolis <christos@FreeBSD.org>
AuthorDate: 2026-11-13 12:48:09 +0000
Commit: Christos Margiolis <christos@FreeBSD.org>
CommitDate: 2026-11-14 09:49:14 +0000
snd_uaudio: Do not touch mixer_lock when there is no mixer
Using the mixer lock unconditionally panics because the lock is
uninitialized on devices with no audio interfaces, for instance
MIDI-only keyboards.
Fixes: 9a00e0b8ca56 ("snd_uaudio: Do not use snd_mixer->lock as mixer_lock")
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D61506
---
sys/dev/sound/usb/uaudio.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/sys/dev/sound/usb/uaudio.c b/sys/dev/sound/usb/uaudio.c
index fc4891aff2ee..f918e1245c47 100644
--- a/sys/dev/sound/usb/uaudio.c
+++ b/sys/dev/sound/usb/uaudio.c
@@ -1148,7 +1148,11 @@ uaudio_attach(device_t dev)
bus_attach_children(dev);
- if (uaudio_handle_hid) {
+ /*
+ * Gate on mixer_dev, otherwise a device with no audio interfaces, such
+ * as a MIDI-only keyboard, will end up using an uninitialized mutex.
+ */
+ if (uaudio_handle_hid && sc->sc_child[0].mixer_dev != NULL) {
if (uaudio_hid_attach(sc, uaa) == 0) {
device_printf(dev, "HID volume keys found.\n");
} else {
@@ -1157,7 +1161,8 @@ uaudio_attach(device_t dev)
}
/* reload all mixer settings */
- uaudio_mixer_reload_all(sc);
+ if (sc->sc_child[0].mixer_dev != NULL)
+ uaudio_mixer_reload_all(sc);
/* enable S/PDIF output, if any */
if (sc->sc_set_spdif_fn(sc,