Skip to content

Commit

Permalink
fixup! ASoC: SOF: topology: dynamically allocate and store DAI widget…
Browse files Browse the repository at this point in the history
…->private

Prevent NULL pointer dereference when freeing the DAI widgets in DSPless
mode.
commit b0490cc ("ASoC: SOF: topology: dynamically allocate and store DAI widget->private")
now sets swidget->priv to non NULL so the sof_widget_free_unlocked()
is executed and we get a NULL dereference when reaching to
swidget->spipe->pipe_widget

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
  • Loading branch information
ujfalusi authored and plbossart committed Nov 30, 2023
1 parent 11dced3 commit 4316522
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions sound/soc/sof/sof-audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ static int sof_widget_free_unlocked(struct snd_sof_dev *sdev,
{
const struct sof_ipc_tplg_ops *tplg_ops = sof_ipc_get_ops(sdev, tplg);
struct snd_sof_pipeline *spipe = swidget->spipe;
struct snd_sof_widget *pipe_widget;
int err = 0;
int ret;

Expand All @@ -59,8 +58,6 @@ static int sof_widget_free_unlocked(struct snd_sof_dev *sdev,
if (--swidget->use_count)
return 0;

pipe_widget = swidget->spipe->pipe_widget;

/* reset route setup status for all routes that contain this widget */
sof_reset_route_setup_status(sdev, swidget);

Expand Down Expand Up @@ -109,8 +106,9 @@ static int sof_widget_free_unlocked(struct snd_sof_dev *sdev,
* free the scheduler widget (same as pipe_widget) associated with the current swidget.
* skip for static pipelines
*/
if (swidget->dynamic_pipeline_widget && swidget->id != snd_soc_dapm_scheduler) {
ret = sof_widget_free_unlocked(sdev, pipe_widget);
if (swidget->spipe && swidget->dynamic_pipeline_widget &&
swidget->id != snd_soc_dapm_scheduler) {
ret = sof_widget_free_unlocked(sdev, swidget->spipe->pipe_widget);
if (ret < 0 && !err)
err = ret;
}
Expand Down

0 comments on commit 4316522

Please sign in to comment.