Skip to contentSkip to conversation

ALSA: hda: intel: Don't free card in the probe work

PATCH Applied Ali Ahmet Memiş 2 participants 2 messages Oct 12 – Oct 13 Sound

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 ALSA: hda: intel: Don't free card in the probe work

If the delayed probe fails, azx_probe_work() frees the card and clears the drvdata. azx_remove() reads the card before it waits for the probe work with cancel_delayed_work_sync() so when the device is removed while the probe work is running, it frees the card again after the work has already freed it.

Only disconnect the card in the work so that its slot is released right away and leave freeing it to azx_remove().

Fixes 39173303c838 ("ALSA: hda: Free card instance properly at probe errors")
Reported-by [email protected]

---
v2: disconnect the card in the work so that the slot is released (Takashi)
v1: https://lore.kernel.org/all/[email protected]/

 sound/hda/controllers/intel.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
sound/hda/controllers/intel.c +6 -1
index 2b5b5d555f2c..6b80b59b8743 100644
@@ -1737,7 +1737,12 @@ static void azx_check_snoop_available(struct azx *chip)
 static void azx_probe_work(struct work_struct *work)
 {
 	struct hda_intel *hda = container_of(work, struct hda_intel, probe_work.work);
-	azx_probe_continue(&hda->chip, true);
+
+	if (azx_probe_continue(&hda->chip, false) < 0) {
+		hda->init_failed = 1;
+		complete_all(&hda->probe_wait);
+		snd_card_disconnect(hda->chip.card);
+	}
 }
 
 static int default_bdl_pos_adj(struct azx *chip)
Signature · 1 line
2.55.0
Applied
#1 lore raw
Quoted 7 lines · Ali Ahmet Memiş

If the delayed probe fails, azx_probe_work() frees the card and clears the drvdata. azx_remove() reads the card before it waits for the probe work with cancel_delayed_work_sync() so when the device is removed while the probe work is running, it frees the card again after the work has already freed it.

Quoted 7 lines

Only disconnect the card in the work so that its slot is released right away and leave freeing it to azx_remove().

Fixes 39173303c838 ("ALSA: hda: Free card instance properly at probe errors")
Reported-by [email protected]

Applied to for-next branch now. Thanks.

Takashi