Re: [PATCH v2] ASoC: SOF: ipc4-topology: Fix pin format leak in process widget setup

From: Péter Ujfalusi

Date: Mon Nov 09 2026 - 02:14:39 EST




On 09/11/2026 02:56, Baoli Zhang wrote:
> sof_ipc4_widget_setup_comp_process() allocates the input and output pin
> format arrays via sof_ipc4_get_audio_fmt(). When the following
> sof_ipc4_widget_setup_msg() fails, e.g. because the firmware does not
> provide a module matching the widget UUID, the error path jumps to the
> 'err' label, which frees the process struct and clears swidget->private
> but skips sof_ipc4_free_audio_fmt(). The arrays are then unreachable and
> are reported by kmemleak:
>
> sof_ipc4_get_audio_fmt+0xc9/0x420 [snd_sof]
> sof_ipc4_widget_setup_comp_process+0x8e/0x200 [snd_sof]
> snd_sof_load_topology+0x71a/0x840 [snd_sof]
> sof_pcm_probe+0x77/0x120 [snd_sof]
> snd_soc_component_probe+0x21/0x60 [snd_soc_core]
> ...
>
> Jump to 'free_available_fmt' instead, as the other process widget error
> paths after sof_ipc4_get_audio_fmt() already do.
>
> The other IPC4 widget setup functions (pga, mixer, src, asrc) free the
> audio formats in their common error label and are not affected.
>
> Fixes: f9efae954905 ("ASoC: SOF: ipc4-topology: Add support for base config extension")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Baoli Zhang <baoli.zhang@xxxxxxxxxxxxxxx>

Acked-by: Peter Ujfalusi <peter.ujfalusi@xxxxxxxxxxxxxxx>

> ---
> Changes in v2:
> - Drop the Assisted-by tag.
> - v1: https://lore.kernel.org/linux-sound/20261103021710.3647599-1-baoli.zhang@xxxxxxxxxxxxxxx/
>
> sound/soc/sof/ipc4-topology.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/sound/soc/sof/ipc4-topology.c b/sound/soc/sof/ipc4-topology.c
> index 8b13c97b34804..de03dc58021a1 100644
> --- a/sound/soc/sof/ipc4-topology.c
> +++ b/sound/soc/sof/ipc4-topology.c
> @@ -1313,7 +1313,7 @@ static int sof_ipc4_widget_setup_comp_process(struct snd_sof_widget *swidget)
>
> ret = sof_ipc4_widget_setup_msg(swidget, &process->msg);
> if (ret)
> - goto err;
> + goto free_available_fmt;
>
> /* parse process init module payload config type from module info */
> fw_module = swidget->module_info;
>
> base-commit: 3ecd14f81434da3b5ff5c44d243715f96d52303d

--
Péter