git: f679f13f6274 - releng/15.2 - sound: Unlock the channel when chn_reset() fails in dsp_chn_alloc()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 25 Nov 2026 22:11:17 UTC
The branch releng/15.2 has been updated by cperciva:
URL: https://cgit.FreeBSD.org/src/commit/?id=f679f13f6274e13e2cf95728046143bfeeb6fc8d
commit f679f13f6274e13e2cf95728046143bfeeb6fc8d
Author: Christos Margiolis <christos@FreeBSD.org>
AuthorDate: 2026-11-20 18:47:25 +0000
Commit: Colin Percival <cperciva@FreeBSD.org>
CommitDate: 2026-11-25 22:09:18 +0000
sound: Unlock the channel when chn_reset() fails in dsp_chn_alloc()
If chn_reset() fails, dsp_chn_alloc() returns with the channel lock
held, dsp_open() calls dsp_close() as part of its cdevpriv error path,
and this causes both a mutex recursion on the channel lock in
dsp_close(), as well a lock order reversal.
Approved by: re (cperciva)
Fixes: 02d4eeabfd73 ("sound: Allocate vchans on-demand")
Reported by: llm-postcr
MFC after: Immediately
Sponsored by: The FreeBSD Foundation
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D61793
(cherry picked from commit 01a8cd5ebe9368fd115fb5060bcb1e60d1bbdf1f)
(cherry picked from commit 55b89b7b529f1c37a749adadb11aba4f8e9e51ca)
---
sys/dev/sound/pcm/dsp.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/sys/dev/sound/pcm/dsp.c b/sys/dev/sound/pcm/dsp.c
index 520d742765ce..e82a0169ddf6 100644
--- a/sys/dev/sound/pcm/dsp.c
+++ b/sys/dev/sound/pcm/dsp.c
@@ -246,8 +246,10 @@ dsp_chn_alloc(struct snddev_info *d, struct pcm_channel **ch, int direction,
strlcpy((*ch)->comm, (comm != NULL) ? comm : CHN_COMM_UNKNOWN,
sizeof((*ch)->comm));
- if ((err = chn_reset(*ch, (*ch)->format, (*ch)->speed)) != 0)
+ if ((err = chn_reset(*ch, (*ch)->format, (*ch)->speed)) != 0) {
+ CHN_UNLOCK(*ch);
return (err);
+ }
chn_vpc_reset(*ch, SND_VOL_C_PCM, 0);
CHN_UNLOCK(*ch);