Skip to content
This repository was archived by the owner on Aug 27, 2025. It is now read-only.

Commit 0957092

Browse files
pelwellpopcornmix
authored andcommitted
dtoverlay: Don't mix non-fatal errors and offsets
FDT errors are small negative integers, and non-fatal errors are the positive versions of the same errors. This scheme only works if the non-fatal error values are never returned from a function where a positive integer has another interpretation. dtoverlay_get_target_offset broke this rule, leading eventually to an invalid DT and failure to boot. Fortunately, finding the offset for a fragment target is a non-destructive operation and therefore always non-fatal, so move the NON_FATAL classification to the callers - of which there are only three. See: raspberrypi/firmware#1686
1 parent affef1e commit 0957092

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

helpers/dtoverlay/dtoverlay.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -976,7 +976,7 @@ static int dtoverlay_get_target_offset(DTBLOB_T *base_dtb,
976976
if (target_off < 0)
977977
{
978978
dtoverlay_error("invalid target-path '%.*s'", len, target_path);
979-
return NON_FATAL(target_off);
979+
return target_off;
980980
}
981981
}
982982
else
@@ -988,11 +988,11 @@ static int dtoverlay_get_target_offset(DTBLOB_T *base_dtb,
988988
if (!target_prop)
989989
{
990990
dtoverlay_error("no target or target-path");
991-
return NON_FATAL(len);
991+
return len;
992992
}
993993

994994
if (len != 4)
995-
return NON_FATAL(FDT_ERR_BADSTRUCTURE);
995+
return -FDT_ERR_BADSTRUCTURE;
996996

997997
phandle = fdt32_to_cpu(*(fdt32_t *)target_prop);
998998
if (!base_dtb)
@@ -1007,7 +1007,7 @@ static int dtoverlay_get_target_offset(DTBLOB_T *base_dtb,
10071007
if (target_off < 0)
10081008
{
10091009
dtoverlay_error("invalid target (phandle %d)", phandle);
1010-
return NON_FATAL(target_off);
1010+
return target_off;
10111011
}
10121012
}
10131013

@@ -1071,7 +1071,7 @@ static int dtoverlay_apply_overlay_paths(DTBLOB_T *base_dtb, int strings_off,
10711071
target_off = dtoverlay_get_target_offset(base_dtb, overlay_dtb,
10721072
sym_frag_off);
10731073
if (target_off < 0)
1074-
return target_off;
1074+
return NON_FATAL(target_off);
10751075

10761076
err = fdt_get_path(base_dtb->fdt, target_off,
10771077
target_path, sizeof(target_path));
@@ -1239,7 +1239,7 @@ int dtoverlay_merge_overlay(DTBLOB_T *base_dtb, DTBLOB_T *overlay_dtb)
12391239
target_off = dtoverlay_get_target_offset(base_dtb, overlay_dtb, frag_off);
12401240
if (target_off < 0)
12411241
{
1242-
err = target_off;
1242+
err = NON_FATAL(target_off);
12431243
break;
12441244
}
12451245

0 commit comments

Comments
 (0)