]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
of: overlay: Call of_changeset_init() early
authorGeert Uytterhoeven <geert+renesas@glider.be>
Fri, 28 Jul 2023 08:50:28 +0000 (10:50 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 13 Sep 2023 07:48:19 +0000 (09:48 +0200)
commitbe86241bf5d1efd16d8a7231c13b33459c5d755d
treeb5c8cc049816e3cd95c8af742e1710fdd69119cf
parent70bd7f65d33ddb28451f38c3e6b1b825f202f87a
of: overlay: Call of_changeset_init() early

[ Upstream commit a9515ff4fb142b690a0d2b58782b15903b990dba ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/of/overlay.c