ASoC: SOF: sof-audio: Fix error path in sof_widget_setup_unlocked()#5798
ASoC: SOF: sof-audio: Fix error path in sof_widget_setup_unlocked()#5798ujfalusi wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes error handling in sof_widget_setup_unlocked() to prevent double-cleanup (double use_count decrement and duplicate pipeline/core teardown) when tplg_ops->dai_config() or widget_kcontrol_setup() fails during widget setup.
Changes:
- After calling
sof_widget_free_unlocked()in thewidget_free:error path, jump directly touse_count_decto avoid re-running thepipe_widget_freecleanup logic.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| sof_widget_free_unlocked(sdev, swidget); | ||
| use_count_decremented = true; | ||
| /* sof_widget_free_unlocked already cleaned up pipe_widget/cores */ | ||
| goto use_count_dec; |
There was a problem hiding this comment.
use_count is decremented in sof_widget_free_unlocked() and we set use_count_decremented = true; above. That means swidget->use_count will not be decremented after the use_count_dec: label. Why don't we return ret here?
There was a problem hiding this comment.
yes, you are right! we should just return from here.
There was a problem hiding this comment.
and we can also remove the use_count_decremented as well ..
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>
7aea88b to
2c9f0c0
Compare
|
Changes since v1:
|
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.
The code between pipe_widget_free and use_count_dec is done within sof_widget_free_unlocked() and we need to skip it during error handling.
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")