[Intel-gfx] [PATCH v2] ALSA: hda: handle UAF at probe error
Nirmoy Das
nirmoy.das at intel.com
Thu Apr 14 18:31:47 UTC 2022
Call snd_card_free_on_error() on probe error instead of
calling snd_card_free() which should handle devres call orders.
Issues: https://gitlab.freedesktop.org/drm/intel/-/issues/5701
Fixes: e8ad415b7a55 ("ALSA: core: Add managed card creation")
Signed-off-by: Nirmoy Das <nirmoy.das at intel.com>
---
sound/pci/hda/hda_intel.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index 82a45f2b31c4..eb4228c9e37f 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -1730,7 +1730,9 @@ 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);
+ struct azx *chip = &hda->chip;
+
+ snd_card_free_on_error(&chip->pci->dev, azx_probe_continue(chip));
}
static int default_bdl_pos_adj(struct azx *chip)
@@ -2028,7 +2030,7 @@ static void azx_firmware_cb(const struct firmware *fw, void *context)
dev_err(card->dev, "Cannot load firmware, continue without patching\n");
if (!chip->disabled) {
/* continue probing */
- azx_probe_continue(chip);
+ snd_card_free_on_error(&chip->pci->dev, azx_probe_continue(chip));
}
}
#endif
@@ -2338,7 +2340,6 @@ static int azx_probe_continue(struct azx *chip)
out_free:
if (err < 0) {
pci_set_drvdata(pci, NULL);
- snd_card_free(chip->card);
return err;
}
--
2.35.1
More information about the Intel-gfx
mailing list