Skip to content

Commit

Permalink
ASoC: SOF: ipc4-topology: check dai->private in ipc_free()
Browse files Browse the repository at this point in the history
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: 2cabd02 ("ASoC: SOF: ipc4-topology: Add support for parsing AIF_IN/AIF_OUT widgets")
Fixes: abfb536 ("ASoC: SOF: ipc4-topology: Add support for parsing DAI_IN/DAI_OUT widgets")
Fixes: 4f838ab ("ASoC: SOF: ipc4-topology: Add support for parsing and preparing pga widgets")
Fixes: 4d4ba01 ("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>
  • Loading branch information
libinyang authored and broonie committed Jul 8, 2022
1 parent 050237e commit b737fd8
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions sound/soc/sof/ipc4-topology.c
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ static int sof_ipc4_widget_setup_pcm(struct snd_sof_widget *swidget)
kfree(available_fmt->dma_buffer_size);
free_copier:
kfree(ipc4_copier);
swidget->private = NULL;
return ret;
}

Expand Down Expand Up @@ -541,6 +542,8 @@ static int sof_ipc4_widget_setup_comp_dai(struct snd_sof_widget *swidget)
kfree(available_fmt->dma_buffer_size);
free_copier:
kfree(ipc4_copier);
dai->private = NULL;
dai->scomp = NULL;
return ret;
}

Expand All @@ -553,6 +556,12 @@ static void sof_ipc4_widget_free_comp_dai(struct snd_sof_widget *swidget)
if (!dai)
return;

if (!dai->private) {
kfree(dai);
swidget->private = NULL;
return;
}

ipc4_copier = dai->private;
available_fmt = &ipc4_copier->available_fmt;

Expand Down Expand Up @@ -669,6 +678,7 @@ static int sof_ipc4_widget_setup_comp_pga(struct snd_sof_widget *swidget)
return 0;
err:
kfree(gain);
swidget->private = NULL;
return ret;
}

Expand Down Expand Up @@ -698,6 +708,7 @@ static int sof_ipc4_widget_setup_comp_mixer(struct snd_sof_widget *swidget)
return 0;
err:
kfree(mixer);
swidget->private = NULL;
return ret;
}

Expand Down

0 comments on commit b737fd8

Please sign in to comment.