ASoC: SOF: ipc4-topology: Return error for invalid number of formats

When the number of input or output formats is zero,
sof_ipc4_widget_setup_comp_src() and sof_ipc4_widget_setup_comp_asrc()
print an error and jump to the cleanup label. At that point 'ret' is
still 0, because the earlier sof_ipc4_get_audio_fmt() call succeeded, so
the function returns success and the caller never finds out that the
widget setup actually failed.

Set ret to -EINVAL before the goto so the error gets reported.

Fixes: 21a5adffad ("ASoC: SOF: ipc4-topology: Validate the number of in/out formats for src/asrc")
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <error27@gmail.com>
Closes: https://lore.kernel.org/r/202606111431.Uky3T0tF-lkp@intel.com/
Signed-off-by: Mert Seftali <mertsftl@gmail.com>
Link: https://patch.msgid.link/20260614124019.19259-1-mertsftl@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Mert Seftali 2026-06-14 14:40:19 +02:00 committed by Mark Brown
parent dc59e4fea9
commit 11e828cd6b
No known key found for this signature in database
GPG Key ID: 24D68B725D5487D0

View File

@ -1127,6 +1127,7 @@ static int sof_ipc4_widget_setup_comp_src(struct snd_sof_widget *swidget)
"Invalid number of formats: input: %d, output: %d\n",
src->available_fmt.num_input_formats,
src->available_fmt.num_output_formats);
ret = -EINVAL;
goto err;
}
@ -1179,6 +1180,7 @@ static int sof_ipc4_widget_setup_comp_asrc(struct snd_sof_widget *swidget)
"Invalid number of formats: input: %d, output: %d\n",
asrc->available_fmt.num_input_formats,
asrc->available_fmt.num_output_formats);
ret = -EINVAL;
goto err;
}