Commit e385b0ba authored by Geert Uytterhoeven's avatar Geert Uytterhoeven Committed by Rob Herring

of: overlay: Move devicetree_corrupt() check up

There is no point in doing several preparatory steps in
of_overlay_fdt_apply(), only to see of_overlay_apply() return early
because of a corrupt device tree.

Move the check for a corrupt device tree from of_overlay_apply() to
of_overlay_fdt_apply(), to check for this as early as possible.
Signed-off-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: default avatarFrank Rowand <frank.rowand@sony.com>
Tested-by: default avatarFrank Rowand <frank.rowand@sony.com>
Signed-off-by: default avatarRob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/c91ce7112eb5167ea46a43d8a980e76b920010ba.1657893306.git.geert+renesas@glider.be
parent 2aa0d4c8
......@@ -903,12 +903,6 @@ static int of_overlay_apply(struct overlay_changeset *ovcs)
{
int ret = 0, ret_revert, ret_tmp;
if (devicetree_corrupt()) {
pr_err("devicetree state suspect, refuse to apply overlay\n");
ret = -EBUSY;
goto out;
}
ret = of_resolve_phandles(ovcs->overlay_root);
if (ret)
goto out;
......@@ -983,6 +977,11 @@ int of_overlay_fdt_apply(const void *overlay_fdt, u32 overlay_fdt_size,
*ret_ovcs_id = 0;
if (devicetree_corrupt()) {
pr_err("devicetree state suspect, refuse to apply overlay\n");
return -EBUSY;
}
if (overlay_fdt_size < sizeof(struct fdt_header) ||
fdt_check_header(overlay_fdt)) {
pr_err("Invalid overlay_fdt header\n");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment