Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

of: overlay: Call of_changeset_init() early

When of_overlay_fdt_apply() fails, the changeset may be partially
applied, and the caller is still expected to call of_overlay_remove() to
clean up this partial state.

However, of_overlay_apply() calls of_resolve_phandles() before
init_overlay_changeset(). Hence if the overlay fails to apply due to an
unresolved symbol, the overlay_changeset.cset.entries list is still
uninitialized, and cleanup will crash with a NULL-pointer dereference in
overlay_removal_is_ok().

Fix this by moving the call to of_changeset_init() from
init_overlay_changeset() to of_overlay_fdt_apply(), where all other
early initialization is done.

Fixes: f948d6d8b792bb90 ("of: overlay: avoid race condition between applying multiple overlays")
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/4f1d6d74b61cba2599026adb6d1948ae559ce91f.1690533838.git.geert+renesas@glider.be
Signed-off-by: Rob Herring <robh@kernel.org>

authored by

Geert Uytterhoeven and committed by
Rob Herring
a9515ff4 500d4510

+1 -2
+1 -2
drivers/of/overlay.c
··· 769 769 if (!of_node_is_root(ovcs->overlay_root)) 770 770 pr_debug("%s() ovcs->overlay_root is not root\n", __func__); 771 771 772 - of_changeset_init(&ovcs->cset); 773 - 774 772 cnt = 0; 775 773 776 774 /* fragment nodes */ ··· 1031 1033 1032 1034 INIT_LIST_HEAD(&ovcs->ovcs_list); 1033 1035 list_add_tail(&ovcs->ovcs_list, &ovcs_list); 1036 + of_changeset_init(&ovcs->cset); 1034 1037 1035 1038 /* 1036 1039 * Must create permanent copy of FDT because of_fdt_unflatten_tree()