mirror of
https://github.com/freebsd/freebsd-src.git
synced 2026-10-28 11:25:21 +01:00
Since3107b952f5("sound: Merge PCM_ALIVE() with PCM_REGISTERED()"), pcm_unregister() is gated on PCM_REGISTERED(), so it cannot run unless pcm_register() has already succeeded, which means drivers will leak resources if a failure happened prior to this. Reintroduce PCM_ALIVE(), but test dev rather than the lock. pcm_init() assigns dev before anything else, so it can tell us whether pcm_init() has run or not. Make sure to clear it in pcm_unregister() so that a second call to pcm_unregister() cannot double-free. While here, publish to sndstat(4) only once pcm_register() has succeeded. Reported by: jah Fixes:3107b952f5("sound: Merge PCM_ALIVE() with PCM_REGISTERED()") MFC after: 1 week Sponsored by: The FreeBSD Foundation Reviewed by: jah, markj Differential Revision: https://reviews.freebsd.org/D60801