Files
Christos Margiolis 5760c22a05 sound: Let pcm_unregister() tear down a partially initialized device
Since 3107b952f5 ("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
2026-10-27 12:26:29 +01:00
..
…
2026-10-08 08:19:22 -04:00
2026-10-08 08:19:22 -04:00
…
2026-10-08 08:19:22 -04:00
…
2026-10-08 08:19:22 -04:00
2026-10-08 08:19:22 -04:00
2026-10-08 08:19:22 -04:00
2026-10-08 08:19:22 -04:00
2026-10-08 08:19:22 -04:00
…
2026-10-08 08:19:22 -04:00
2026-10-08 08:19:22 -04:00
…
2026-10-08 08:19:22 -04:00
…