Linux Sound subsystem development
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Cezary Rojewski <cezary.rojewski@intel.com>
Cc: broonie@kernel.org, tiwai@suse.com, perex@perex.cz,
	amade@asmblr.net, linux-sound@vger.kernel.org
Subject: Re: [PATCH v3 01/10] ALSA: hda: ext: Clean up links if their initialization fails
Date: Tue, 01 Sep 2026 13:39:16 +0200	[thread overview]
Message-ID: <87tso9ciaj.wl-tiwai@suse.de> (raw)
In-Reply-To: <20260831164233.1487766-2-cezary.rojewski@intel.com>

On Mon, 31 Aug 2026 18:42:24 +0200,
Cezary Rojewski wrote:
> 
> snd_hdac_ext_bus_get_ml_capabilities() allocates the hlink nodes
> one-by-one but the procedure may fails due to -ENOMEM in the middle of
> it. Clean up the list before returning the error code to simply the
> function usage.
> 
> Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
> ---
>  sound/hda/core/ext/controller.c | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/sound/hda/core/ext/controller.c b/sound/hda/core/ext/controller.c
> index b1f1eff1d181..f75d3dcc6cb2 100644
> --- a/sound/hda/core/ext/controller.c
> +++ b/sound/hda/core/ext/controller.c
> @@ -81,7 +81,7 @@ int snd_hdac_ext_bus_get_ml_capabilities(struct hdac_bus *bus)
>  {
>  	int idx;
>  	u32 link_count;
> -	struct hdac_ext_link *hlink;
> +	struct hdac_ext_link *hlink, *save;
>  	u32 leptr;
>  
>  	link_count = readl(bus->mlcap + AZX_REG_ML_MLCD) + 1;
> @@ -91,7 +91,7 @@ int snd_hdac_ext_bus_get_ml_capabilities(struct hdac_bus *bus)
>  	for (idx = 0; idx < link_count; idx++) {
>  		hlink = kzalloc_obj(*hlink);
>  		if (!hlink)
> -			return -ENOMEM;
> +			goto err_nomem;
>  		hlink->index = idx;
>  		hlink->bus = bus;
>  		hlink->ml_addr = bus->mlcap + AZX_ML_BASE +
> @@ -112,6 +112,13 @@ int snd_hdac_ext_bus_get_ml_capabilities(struct hdac_bus *bus)
>  	}
>  
>  	return 0;
> +
> +err_nomem:
> +	list_for_each_entry_safe(hlink, save, &bus->hlink_list, list) {
> +		list_del(&hlink->list);
> +		kfree(hlink);
> +	}

You can simply call snd_hdac_ext_link_free_all() instead?


thanks,

Takashi

  reply	other threads:[~2026-09-01 11:39 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-31 16:42 [PATCH v3 00/10] ALSA/ASoC: Intel: avs: HDAudio bus and general fixes Cezary Rojewski
2026-08-31 16:42 ` [PATCH v3 01/10] ALSA: hda: ext: Clean up links if their initialization fails Cezary Rojewski
2026-09-01 11:39   ` Takashi Iwai [this message]
2026-09-01 11:58     ` Cezary Rojewski
2026-08-31 16:42 ` [PATCH v3 02/10] ALSA: hda: ext: Clean up streams " Cezary Rojewski
2026-09-01 11:42   ` Takashi Iwai
2026-09-01 11:49     ` Cezary Rojewski
2026-08-31 16:42 ` [PATCH v3 03/10] ASoC: Intel: avs: Clean up the bus when its " Cezary Rojewski
2026-08-31 16:42 ` [PATCH v3 04/10] ASoC: Intel: avs: Clean up the bus when fetching ML caps fails Cezary Rojewski
2026-08-31 16:42 ` [PATCH v3 05/10] ASoC: Intel: avs: Clean up streams if their initialization fails Cezary Rojewski
2026-08-31 16:42 ` [PATCH v3 06/10] ASoC: Intel: avs: Do not ignore -ENOENT when loading a topology Cezary Rojewski
2026-08-31 16:42 ` [PATCH v3 07/10] ASoC: Intel: avs: Cancel d0ix_work asynchrounously during recovery Cezary Rojewski
2026-08-31 16:42 ` [PATCH v3 08/10] ASoC: Intel: avs: Fix unbalanced module reference count Cezary Rojewski
2026-08-31 16:42 ` [PATCH v3 09/10] ASoC: Intel: avs: Refactor and fix init_config access Cezary Rojewski
2026-08-31 22:30   ` Mark Brown
2026-09-01  8:57     ` Cezary Rojewski
2026-09-01 11:28       ` Mark Brown
2026-08-31 16:42 ` [PATCH v3 10/10] ASoC: Intel: avs: hda: Constrain MSBs on startup 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=87tso9ciaj.wl-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=amade@asmblr.net \
    --cc=broonie@kernel.org \
    --cc=cezary.rojewski@intel.com \
    --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