[PATCH v3 0/2] ALSA: Fix OSS teardown lifetime handling

From: Cen Zhang

Date: Sun Oct 18 2026 - 10:07:43 EST


OSS module unload can race recursive proc entry registration and
notifier callbacks, leaving references to freed entries or unloaded
module code.

Keep the OSS PCM and mixer modules loaded until their objects are
torn down, and serialize notifier traversal and callback withdrawal.

---
Changes in v3:
- Split the PCM core unregister traversal lock into patch 1 and the OSS
module lifecycle changes into patch 2, as requested by Takashi.
- Rename the PCM OSS boolean module_ref to registered; its lifetime still
spans DISCONNECT until final unregister.
- Rebase onto current sound for-next; no additional code changes beyond the
flag rename.

Changes in v2:
- Follow Takashi's suggestion to pin OSS modules until object teardown.
- Track successful PCM pins across disconnect and unregistered cleanup.
- Protect final PCM notifier traversal and mixer callback withdrawal across
the last module reference drop.
- Keep card enumeration in the OSS module and prevent duplicate mixer
REGISTER notifications from replacing a disconnected adapter.
- Leave partial HDA codec teardown for a separate fix.

Link to v1: https://lore.kernel.org/r/pm-pmb-26d66390a25fec9fad6c-v2-743c9b89c0f0d761eda1@xxxxxxxxx
Link to v2: https://lore.kernel.org/r/pm-pmb-26d66390a25fec9fad6c-v4-a7d8a5d3db28c5bca90a@xxxxxxxxx