[PATCH 3/3] ALSA: hda: Make hdac_device.registered a plain bool

From: Takashi Iwai

Date: Wed Oct 07 2026 - 17:57:55 EST


The registered field of hdac_device is a bitfield sharing the same
word with other bitfields like lazy_cache, and those are updated in a
non-atomic read-modify-write manner without any lock. Meanwhile, the
registered flag is read from the unsolicited event worker
concurrently, so the concurrent updates of the neighboring bitfields
may race with it.

Convert it to a plain bool for avoiding such a subtle race. Also
replace the assignments of 0/1 with false/true accordingly.

Assisted-by: LLM
Signed-off-by: Takashi Iwai <tiwai@xxxxxxx>
---
include/sound/hdaudio.h | 2 +-
sound/hda/common/codec.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/sound/hdaudio.h b/include/sound/hdaudio.h
index 285f7c4d262d..04fd4794bcee 100644
--- a/include/sound/hdaudio.h
+++ b/include/sound/hdaudio.h
@@ -96,7 +96,7 @@ struct hdac_device {
bool lazy_cache:1; /* don't wake up for writes */
bool caps_overwriting:1; /* caps overwrite being in process */
bool cache_coef:1; /* cache COEF read/write too */
- unsigned int registered:1; /* codec was registered */
+ bool registered; /* codec was registered */
bool unsol_disabled; /* unsol events blocked; protected by bus->reg_lock */
};

diff --git a/sound/hda/common/codec.c b/sound/hda/common/codec.c
index b79346d01021..c99fe61c29db 100644
--- a/sound/hda/common/codec.c
+++ b/sound/hda/common/codec.c
@@ -761,7 +761,7 @@ void snd_hda_codec_cleanup_for_unbind(struct hda_codec *codec)
/* pm_runtime_put() is called in snd_hdac_device_exit() */
pm_runtime_get_noresume(hda_codec_dev(codec));
pm_runtime_disable(hda_codec_dev(codec));
- codec->core.registered = 0;
+ codec->core.registered = false;
}

snd_hda_codec_disconnect_pcms(codec);
@@ -815,7 +815,7 @@ void snd_hda_codec_register(struct hda_codec *codec)
pm_runtime_enable(hda_codec_dev(codec));
/* it was powered up in snd_hda_codec_new(), now all done */
snd_hda_power_down(codec);
- codec->core.registered = 1;
+ codec->core.registered = true;
}
}
EXPORT_SYMBOL_GPL(snd_hda_codec_register);
--
2.55.0