From af027278d8d9915b7cb32736404719f1aebd66a3 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Wed, 7 Oct 2026 23:56:48 +0200 Subject: [PATCH] ALSA: hda: Make hdac_device.registered a plain bool 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 Link: https://patch.msgid.link/20261007215650.159871-4-tiwai@suse.de --- 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);