Set the swidget->private or dai->private to NULL after kfree in the error
handling in ipc_setup(). The private needs to be set NULL because if
ipc_setup() returns error, ipc_free() will be called later. ipc_free()
will judge the private is NULL or not to do the clearing.
For dai widget, dai->private is allocated and set in dai widget
ipc_setup(). So we need to check dai->private is NULL or not
in the ipc_free().
Fixes: da3d3d4d7e53 ("ASoC: SOF: ipc4-topology: Add support for parsing AIF_IN/AIF_OUT widgets")
Fixes: 56a22c21c176 ("ASoC: SOF: ipc4-topology: Add support for parsing DAI_IN/DAI_OUT widgets")
Fixes: 7c117fe181f0 ("ASoC: SOF: ipc4-topology: Add support for parsing and preparing pga widgets")
Fixes: e63ddc5b09a7 ("ASoC: SOF: ipc4-topology: Add support for parsing mixer widgets")
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Signed-off-by: Libin Yang <libin.yang@intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20220708200516.26853-2-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
kfree(available_fmt->dma_buffer_size);
free_copier:
kfree(ipc4_copier);
+ swidget->private = NULL;
return ret;
}
kfree(available_fmt->dma_buffer_size);
free_copier:
kfree(ipc4_copier);
+ dai->private = NULL;
+ dai->scomp = NULL;
return ret;
}
if (!dai)
return;
+ if (!dai->private) {
+ kfree(dai);
+ swidget->private = NULL;
+ return;
+ }
+
ipc4_copier = dai->private;
available_fmt = &ipc4_copier->available_fmt;
return 0;
err:
kfree(gain);
+ swidget->private = NULL;
return ret;
}
return 0;
err:
kfree(mixer);
+ swidget->private = NULL;
return ret;
}