On 4/15/2022 6:23 AM, Lucas De Marchi wrote:
On Thu, Apr 14, 2022 at 08:24:37PM +0200, Nirmoy Das wrote:
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@intel.com
This failure in i915 CI seems suspicious since is around module removal. https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_102714v1/fi-tgl-1115g4/ig...
Yes, the issue is related to module reload because I can reproduce a UAF by running the module reload test twice.
And it seems it didn't fix the issue in dg2:
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_102714v1/bat-dg2-8/igt@ge...
I guess this is some timing bug around device hotplug as this patch seems to help even though this driver doesn't use devres. I need to check more.
Thanks,
Nirmoy
Lucas De Marchi
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