# Re: \[PATCH 1/7\] clk: fix orphan list iterator to be safe

- From: Turquette, Mike \<hidden\>
- Date: 2012-03-14 02:10:59 
- List: linux-devicetree
- Page: https://ratatoskr.run/linux-devicetree/2012/03/8058464
- Thread: https://ratatoskr.run/linux-arm-kernel/2012/03/8058456/t.md

```text
On Tue, Mar 13, 2012 at 4:22 PM, Rob Herring [ref] wrote:
> From: Rob Herring <redacted>
>
> __clk_reparent can remove orphans, so the list iterator needs to be the
> safe from removal version.
>
> Signed-off-by: Rob Herring <redacted>

Thanks Rob.  I've taken this in for the next series.

Regards,
Mike

> ---
>  drivers/clk/clk.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
> index c7c3bc5..802eda4 100644
> --- a/drivers/clk/clk.c
> +++ b/drivers/clk/clk.c
> @@ -1172,7 +1172,7 @@ void __clk_init(struct device *dev, struct clk *clk)
>  {
>        int i;
>        struct clk *orphan;
> -       struct hlist_node *tmp;
> +       struct hlist_node *tmp, *tmp2;
>
>        if (!clk)
>                return;
> @@ -1246,7 +1246,7 @@ void __clk_init(struct device *dev, struct clk *clk)
>         * walk the list of orphan clocks and reparent any that are children of
>         * this clock
>         */
> -       hlist_for_each_entry(orphan, tmp, &clk_orphan_list, child_node)
> +       hlist_for_each_entry_safe(orphan, tmp, tmp2, &clk_orphan_list, child_node)
>                __clk_reparent(orphan, __clk_init_parent(orphan));
>
>        /*
> --
> 1.7.5.4
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
```
