diff options
author | Peter Ujfalusi <peter.ujfalusi@linux.intel.com> | 2023-01-27 14:00:29 +0200 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2023-01-27 12:14:12 +0000 |
commit | 955a6f131a50c3685c560ef7b75880d272337b33 (patch) | |
tree | fbb566a27906025e7eec4fbfd5adf27da8f5017e /sound/soc/sof/sof-audio.c | |
parent | 6bc4d1b714aafc0ee3c7649c36aa19998b4c11f9 (diff) |
ASoC: SOF: Avoid double decrementing use_count in sof_widget_setup on error
The sof_widget_free() on the error path will decrement the use count and if
we jump to widget_free: then the use_count will be decremented by two,
which is not correct as we only incremented once with 1.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@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/20230127120031.10709-17-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/sof/sof-audio.c')
-rw-r--r-- | sound/soc/sof/sof-audio.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/sound/soc/sof/sof-audio.c b/sound/soc/sof/sof-audio.c index e626a1e0483e..1e785e713bb2 100644 --- a/sound/soc/sof/sof-audio.c +++ b/sound/soc/sof/sof-audio.c @@ -89,6 +89,7 @@ EXPORT_SYMBOL(sof_widget_free); int sof_widget_setup(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget) { const struct sof_ipc_tplg_ops *tplg_ops = sof_ipc_get_ops(sdev, tplg); + bool use_count_decremented = false; int ret; /* skip if there is no private data */ @@ -160,13 +161,16 @@ int sof_widget_setup(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget) widget_free: /* widget use_count and core ref_count will both be decremented by sof_widget_free() */ sof_widget_free(sdev, swidget); + use_count_decremented = true; core_put: snd_sof_dsp_core_put(sdev, swidget->core); pipe_widget_free: if (swidget->id != snd_soc_dapm_scheduler) sof_widget_free(sdev, swidget->spipe->pipe_widget); use_count_dec: - swidget->use_count--; + if (!use_count_decremented) + swidget->use_count--; + return ret; } EXPORT_SYMBOL(sof_widget_setup); |