https://gitlab.synchro.net/main/sbbs/-/commit/bb2f365233ea170ef1506d92
Modified Files:
src/xpdev/xpbeep.c
Log Message:
xpbeep: hold r->mutex when reading auto_close/done in reaper (CIDs 645736, 645739)
xp_audio_open's stream-reaper loop read r->auto_close and r->done while
holding only mixer_lock, but those flags are written elsewhere
(xp_audio_stop, the auto_close setter) under r->mutex only — not
mixer_lock. Coverity flagged the inconsistent locking; in practice it
could let the reaper see stale flag values and either skip a reapable
stream (benign — gets reaped on the next open) or, if a future writer
ever clears done while close-pending, cause a missed reap.
Take r->mutex briefly to read the flags, then release it before free_stream_locked() (which destroys the mutex). Lock order
mixer_lock -> r->mutex matches xp_mixer_pull and xp_audio_close, so no
deadlock risk introduced.
This does NOT address the broader stream_from_handle()-returns-pointer
lifetime issue; that's an architectural concern for a separate change.
Co-Authored-By: Claude Opus 4.7 <
noreply@anthropic.com>
--- SBBSecho 3.37-Linux
* Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)