Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ASoC: SOF: ipc4-topology: Initialize in_format to NULL in sof_ipc4_get_audio_fmt

If the available_fmt->num_input_formats is 0 and there is a failure during
the output format parsing then a kfree() would be called on the
uninitialized in_format pointer.

By initializing the in_format to NULL, this error can be avoided.

Fixes: 7ab6b1e8302c ("ASoC: SOF: ipc4-topology: Modify the type of available input/output formats")
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/20230317063524.8280-1-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Peter Ujfalusi and committed by
Mark Brown
ef51cd1e 1d8777d2

+2 -1
+2 -1
sound/soc/sof/ipc4-topology.c
··· 179 179 struct sof_ipc4_available_audio_format *available_fmt, 180 180 struct sof_ipc4_base_module_cfg *module_base_cfg) 181 181 { 182 - struct sof_ipc4_pin_format *out_format, *in_format; 182 + struct sof_ipc4_pin_format *in_format = NULL; 183 + struct sof_ipc4_pin_format *out_format; 183 184 int ret; 184 185 185 186 ret = sof_update_ipc_object(scomp, available_fmt,