From: Cezary Rojewski <cezary.rojewski@intel.com>
To: broonie@kernel.org
Cc: tiwai@suse.com, perex@perex.cz, amade@asmblr.net,
linux-sound@vger.kernel.org,
Cezary Rojewski <cezary.rojewski@intel.com>
Subject: [PATCH v2 04/11] ASoC: Intel: avs: Clean up the bus when its initialization fails
Date: Mon, 31 Aug 2026 11:36:08 +0200 [thread overview]
Message-ID: <20260831093615.1117987-5-cezary.rojewski@intel.com> (raw)
In-Reply-To: <20260831093615.1117987-1-cezary.rojewski@intel.com>
snd_hdac_i915_init() which is part of the initialization may return
-EPROBE_DEFER what fails the procedure and the existing avs_bus_init()
and avs_pci_probe() do not clean up the bus fields with
snd_hdac_ext_bus_exit() when that happens.
Fix avs_bus_init() by rearranging the initialization blocks: allocations
first, snd_hdac_ext_bus_init() last. Such approach generates no
error-path whilst still achieving the goal of cleaning up the bus.
For avs_pci_probe() update the existing error-path instead.
Co-developed-by: Amadeusz Sławiński <amade@asmblr.net>
Signed-off-by: Amadeusz Sławiński <amade@asmblr.net>
Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
---
sound/soc/intel/avs/core.c | 30 +++++++++++++++++-------------
1 file changed, 17 insertions(+), 13 deletions(-)
diff --git a/sound/soc/intel/avs/core.c b/sound/soc/intel/avs/core.c
index 2afe59646896..f45256ff5bac 100644
--- a/sound/soc/intel/avs/core.c
+++ b/sound/soc/intel/avs/core.c
@@ -383,6 +383,18 @@ static int avs_bus_init(struct avs_dev *adev, struct pci_dev *pci, const struct
struct device *dev = &pci->dev;
int ret;
+ ipc = devm_kzalloc(dev, sizeof(*ipc), GFP_KERNEL);
+ if (!ipc)
+ return -ENOMEM;
+
+ adev->modcfg_buf = devm_kzalloc(dev, AVS_MAILBOX_SIZE, GFP_KERNEL);
+ if (!adev->modcfg_buf)
+ return -ENOMEM;
+
+ ret = avs_ipc_init(ipc, dev);
+ if (ret < 0)
+ return ret;
+
ret = snd_hdac_ext_bus_init(&bus->core, dev, NULL, &soc_hda_ext_bus_ops);
if (ret < 0)
return ret;
@@ -394,17 +406,6 @@ static int avs_bus_init(struct avs_dev *adev, struct pci_dev *pci, const struct
bus->mixer_assigned = -1;
mutex_init(&bus->prepare_mutex);
- ipc = devm_kzalloc(dev, sizeof(*ipc), GFP_KERNEL);
- if (!ipc)
- return -ENOMEM;
- ret = avs_ipc_init(ipc, dev);
- if (ret < 0)
- return ret;
-
- adev->modcfg_buf = devm_kzalloc(dev, AVS_MAILBOX_SIZE, GFP_KERNEL);
- if (!adev->modcfg_buf)
- return -ENOMEM;
-
adev->dev = dev;
adev->spec = (const struct avs_spec *)id->driver_data;
adev->ipc = ipc;
@@ -456,13 +457,14 @@ static int avs_pci_probe(struct pci_dev *pci, const struct pci_device_id *id)
ret = pcim_request_all_regions(pci, "AVS HDAudio");
if (ret < 0)
- return ret;
+ goto err_request_regions;
bus->addr = pci_resource_start(pci, 0);
bus->remap_addr = pci_ioremap_bar(pci, 0);
if (!bus->remap_addr) {
dev_err(bus->dev, "ioremap error\n");
- return -ENXIO;
+ ret = -ENXIO;
+ goto err_request_regions;
}
adev->dsp_ba = pci_ioremap_bar(pci, 4);
@@ -519,6 +521,8 @@ static int avs_pci_probe(struct pci_dev *pci, const struct pci_device_id *id)
iounmap(adev->dsp_ba);
err_remap_bar4:
iounmap(bus->remap_addr);
+err_request_regions:
+ snd_hdac_ext_bus_exit(bus);
return ret;
}
--
2.34.1
next prev parent reply other threads:[~2026-08-31 9:32 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-31 9:36 [PATCH v2 00/11] ALSA/ASoC: Intel: avs: HDAudio bus and general fixes Cezary Rojewski
2026-08-31 9:36 ` [PATCH v2 01/11] ALSA: hda: Clean up pages when stream buffers allocation fails Cezary Rojewski
2026-08-31 9:36 ` [PATCH v2 02/11] ALSA: hda: ext: Clean up links if their initialization fails Cezary Rojewski
2026-08-31 9:36 ` [PATCH v2 03/11] ALSA: hda: ext: Clean up streams " Cezary Rojewski
2026-08-31 9:36 ` Cezary Rojewski [this message]
2026-08-31 9:36 ` [PATCH v2 05/11] ASoC: Intel: avs: Clean up the bus when fetching ML caps fails Cezary Rojewski
2026-08-31 9:36 ` [PATCH v2 06/11] ASoC: Intel: avs: Clean up streams if their initialization fails Cezary Rojewski
2026-08-31 9:36 ` [PATCH v2 07/11] ASoC: Intel: avs: Do not ignore -ENOENT when loading a topology Cezary Rojewski
2026-08-31 9:36 ` [PATCH v2 08/11] ASoC: Intel: avs: Cancel d0ix_work asynchrounously during recovery Cezary Rojewski
2026-08-31 9:36 ` [PATCH v2 09/11] ASoC: Intel: avs: Fix unbalanced module reference count Cezary Rojewski
2026-08-31 9:36 ` [PATCH v2 10/11] ASoC: Intel: avs: Refactor and fix init_config access Cezary Rojewski
2026-08-31 9:36 ` [PATCH v2 11/11] ASoC: Intel: avs: hda: Constrain MSBs on startup Cezary Rojewski
2026-08-31 12:14 ` [PATCH v2 00/11] ALSA/ASoC: Intel: avs: HDAudio bus and general fixes Mark Brown
2026-08-31 13:29 ` Cezary Rojewski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260831093615.1117987-5-cezary.rojewski@intel.com \
--to=cezary.rojewski@intel.com \
--cc=amade@asmblr.net \
--cc=broonie@kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--cc=tiwai@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox