Thank you for your contribution! Sashiko AI review found 1 potential issue(s) 
to consider:
- [High] Incomplete preparation for list iterator semantics change causes DAPM 
power loop to terminate prematurely.
--

commit 43f2e05998002333ccbe3a3f202cf3f76c35d1b0
Author: Kaitao Cheng <[email protected]>

ASoC: dapm: Open-code widget invalidation walk

This commit prepares dapm_widget_invalidate_paths() for an upcoming change
to list_for_each_entry() that will cache the next element. It open-codes the
loop to preserve the existing semantics where new widgets can be appended
during traversal.

> diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
> index d6192204e613d..5bd921fca1323 100644
> --- a/sound/soc/soc-dapm.c
> +++ b/sound/soc/soc-dapm.c
> @@ -255,7 +255,9 @@ static __always_inline void dapm_widget_invalidate_paths(
>       list_add_tail(&w->work_list, &list);
>       w->endpoints[dir] = -1;
>  
> -     list_for_each_entry(w, &list, work_list) {
> +     for (w = list_first_entry(&list, typeof(*w), work_list);
> +          !list_entry_is_head(w, &list, work_list);
> +          w = list_next_entry(w, work_list)) {

[Severity: High]
Does this open-coding also need to be applied to the loop in
dapm_power_widgets()?

dapm_power_widgets() loops over card->dapm_dirty using list_for_each_entry():

sound/soc/soc-dapm.c:dapm_power_widgets() {
        ...
        list_for_each_entry(w, &card->dapm_dirty, dirty) {
                dapm_power_one_widget(w, &up_list, &down_list);
        }
        ...
}

Inside that loop, dapm_power_one_widget() can invoke
dapm_widget_set_peer_power(), which calls dapm_mark_dirty() to append peer
widgets to the tail of card->dapm_dirty.

If the upcoming list_for_each_entry() changes cache the next element, won't
the loop in dapm_power_widgets() terminate early and fail to process newly
dirtied widgets if they are appended while processing the current tail
element?

-- 
Sashiko AI review · 
https://sashiko.dev/#/patchset/[email protected]?part=13

Reply via email to