Skip to contentSkip to conversation

ALSA: hda: Skip codec shutdown in case the codec is not registered

PATCH Applied Peter Ujfalusi 2 participants 2 messages Feb 1, 2022 Sound

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ALSA: hda: Skip codec shutdown in case the codec is not registered

If the codec->registered is not set then it means that pm_runtime is not yet enabled and the codec->pcm_list_head has not been initialized.

The access to the not initialized pcm_list_head will lead a kernel crash during shutdown.

---
 sound/pci/hda/hda_codec.c | 4 ++++
 1 file changed, 4 insertions(+)
sound/pci/hda/hda_codec.c +4 -0
index 7016b48227bf..f552785d301e 100644
@@ -3000,6 +3000,10 @@ void snd_hda_codec_shutdown(struct hda_codec *codec)
 {
 	struct hda_pcm *cpcm;
 
+	/* Skip the shutdown if codec is not registered */
+	if (!codec->registered)
+		return;
+
 	list_for_each_entry(cpcm, &codec->pcm_list_head, list)
 		snd_pcm_suspend_all(cpcm->pcm);
 
Signature · 1 line
2.35.0
Applied
#1 lore raw
Quoted 10 lines · Peter Ujfalusi

If the codec->registered is not set then it means that pm_runtime is not yet enabled and the codec->pcm_list_head has not been initialized.

The access to the not initialized pcm_list_head will lead a kernel crash during shutdown.

Thanks, applied now.

Takashi