git: fab137d23462 - stable/14 - sound: Add missing CHN_[UN]LOCKs in sndstat
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 10 Jul 2024 16:49:13 UTC
The branch stable/14 has been updated by christos:
URL: https://cgit.FreeBSD.org/src/commit/?id=fab137d2346252f210417e9dee0ca190d5cbe198
commit fab137d2346252f210417e9dee0ca190d5cbe198
Author: Christos Margiolis <christos@FreeBSD.org>
AuthorDate: 2024-07-06 18:23:22 +0000
Commit: Christos Margiolis <christos@FreeBSD.org>
CommitDate: 2024-07-10 16:48:13 +0000
sound: Add missing CHN_[UN]LOCKs in sndstat
In sndstat_build_sound4_nvlist(), if we have INVARIANTS or
SND_DIAGNOSTIC enabled, we will hit a lock assertion panic when we call
CHN_GETVOLUME(). Also lock the channel in the sndstat_prepare_pcm() loop
for good measure.
Fixes: bbca3a75bb41 ("sound: Include sound(4) channel information in sndstat nvlist")
Sponsored by: The FreeBSD Foundation
MFC after: 2 days
Reviewed by: dev_submerge.ch
Differential Revision: https://reviews.freebsd.org/D45898
(cherry picked from commit e850bd36dfda98608432d2459800627d16119fec)
---
sys/dev/sound/pcm/sndstat.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/sys/dev/sound/pcm/sndstat.c b/sys/dev/sound/pcm/sndstat.c
index 5b770810d19b..753531f3694e 100644
--- a/sys/dev/sound/pcm/sndstat.c
+++ b/sys/dev/sound/pcm/sndstat.c
@@ -456,6 +456,8 @@ sndstat_build_sound4_nvlist(struct snddev_info *d, nvlist_t **dip)
goto done;
}
+ CHN_LOCK(c);
+
nvlist_add_string(cdi, SNDST_DSPS_SOUND4_CHAN_NAME, c->name);
nvlist_add_string(cdi, SNDST_DSPS_SOUND4_CHAN_PARENTCHAN,
c->parentchannel != NULL ? c->parentchannel->name : "");
@@ -537,6 +539,8 @@ sndstat_build_sound4_nvlist(struct snddev_info *d, nvlist_t **dip)
sbuf_printf(&sb, "%s]",
(c->direction == PCMDIR_REC) ? "userland" : "hardware");
+ CHN_UNLOCK(c);
+
sbuf_finish(&sb);
nvlist_add_string(cdi, SNDST_DSPS_SOUND4_CHAN_FEEDERCHAIN,
sbuf_data(&sb));
@@ -1230,6 +1234,8 @@ sndstat_prepare_pcm(struct sbuf *s, device_t dev, int verbose)
KASSERT(c->bufhard != NULL && c->bufsoft != NULL,
("hosed pcm channel setup"));
+ CHN_LOCK(c);
+
sbuf_printf(s, "\n\t");
sbuf_printf(s, "%s[%s]: ",
@@ -1321,6 +1327,8 @@ sndstat_prepare_pcm(struct sbuf *s, device_t dev, int verbose)
}
sbuf_printf(s, "{%s}",
(c->direction == PCMDIR_REC) ? "userland" : "hardware");
+
+ CHN_UNLOCK(c);
}
return (0);