git: 01a8cd5ebe93 - main - sound: Unlock the channel when chn_reset() fails in dsp_chn_alloc()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 20 Nov 2026 18:48:07 UTC
The branch main has been updated by christos:
URL: https://cgit.FreeBSD.org/src/commit/?id=01a8cd5ebe9368fd115fb5060bcb1e60d1bbdf1f
commit 01a8cd5ebe9368fd115fb5060bcb1e60d1bbdf1f
Author: Christos Margiolis <christos@FreeBSD.org>
AuthorDate: 2026-11-20 18:47:25 +0000
Commit: Christos Margiolis <christos@FreeBSD.org>
CommitDate: 2026-11-20 18:47:25 +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.
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
---
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 77faac3b5589..5d1b4b2b22d4 100644
--- a/sys/dev/sound/pcm/dsp.c
+++ b/sys/dev/sound/pcm/dsp.c
@@ -238,8 +238,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);