Skip to content

Commit 2c9f0c0

Browse files
committed
ASoC: SOF: sof-audio: Fix error path in sof_widget_setup_unlocked()
If either tplg_ops->dai_config or widget_kcontrol_setup fail during widget setup we would double decrement the use_count of the widget because the sof_widget_free_unlocked() would be called twice, similarly the core_put would be invoked twice as well. Since the use_count and core_put() is handled within the widget_free function we need to return without falling through the pipe_widget_free label. The fixes tag is picked to the last change around this part of the code which is adequately old enough for backporting purposes. Link: thesofproject/sof#10826 Fixes: 31ed8da ("ASoC: SOF: sof-audio: Modify logic for enabling/disabling topology cores") Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
1 parent 3a0f2ae commit 2c9f0c0

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

sound/soc/sof/sof-audio.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,6 @@ static int sof_widget_setup_unlocked(struct snd_sof_dev *sdev,
146146
{
147147
const struct sof_ipc_tplg_ops *tplg_ops = sof_ipc_get_ops(sdev, tplg);
148148
struct snd_sof_pipeline *spipe = swidget->spipe;
149-
bool use_count_decremented = false;
150149
int ret;
151150
int i;
152151

@@ -225,9 +224,10 @@ static int sof_widget_setup_unlocked(struct snd_sof_dev *sdev,
225224
return 0;
226225

227226
widget_free:
228-
/* widget use_count will be decremented by sof_widget_free() */
227+
/* widget use_count and core_put handled by sof_widget_free() */
229228
sof_widget_free_unlocked(sdev, swidget);
230-
use_count_decremented = true;
229+
return ret;
230+
231231
pipe_widget_free:
232232
if (swidget->id != snd_soc_dapm_scheduler) {
233233
sof_widget_free_unlocked(sdev, swidget->spipe->pipe_widget);
@@ -242,8 +242,7 @@ static int sof_widget_setup_unlocked(struct snd_sof_dev *sdev,
242242
}
243243
}
244244
use_count_dec:
245-
if (!use_count_decremented)
246-
swidget->use_count--;
245+
swidget->use_count--;
247246

248247
return ret;
249248
}

0 commit comments

Comments
 (0)