Skip to content

Commit 632c60e

Browse files
Dan Carpenterabelvesa
authored andcommitted
clk: imx: scu: use _safe list iterator to avoid a use after free
This loop is freeing "clk" so it needs to use list_for_each_entry_safe(). Otherwise it dereferences a freed variable to get the next item on the loop. Fixes: 77d8f30 ("clk: imx: scu: add two cells binding support") Signed-off-by: Dan Carpenter <[email protected]> Reviewed-by: Abel Vesa <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Abel Vesa <[email protected]>
1 parent 6077af2 commit 632c60e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/clk/imx/clk-scu.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -707,11 +707,11 @@ struct clk_hw *imx_clk_scu_alloc_dev(const char *name,
707707

708708
void imx_clk_scu_unregister(void)
709709
{
710-
struct imx_scu_clk_node *clk;
710+
struct imx_scu_clk_node *clk, *n;
711711
int i;
712712

713713
for (i = 0; i < IMX_SC_R_LAST; i++) {
714-
list_for_each_entry(clk, &imx_scu_clks[i], node) {
714+
list_for_each_entry_safe(clk, n, &imx_scu_clks[i], node) {
715715
clk_hw_unregister(clk->hw);
716716
kfree(clk);
717717
}

0 commit comments

Comments
 (0)