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 <tiwai@suse.de>
Link: https://patch.msgid.link/20261007215650.159871-4-tiwai@suse.de
This commit is contained in:
Takashi Iwai 2026-10-07 23:56:48 +02:00
parent f2c6e4f457
commit af027278d8
2 changed files with 3 additions and 3 deletions

View File

@ -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 */
};

View File

@ -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);