mirror of
https://github.com/raspberrypi/userland.git
synced 2025-12-06 04:49:12 +00:00
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: https://github.com/raspberrypi/firmware/issues/1686
This commit is contained in:
@@ -976,7 +976,7 @@ static int dtoverlay_get_target_offset(DTBLOB_T *base_dtb,
|
||||
if (target_off < 0)
|
||||
{
|
||||
dtoverlay_error("invalid target-path '%.*s'", len, target_path);
|
||||
return NON_FATAL(target_off);
|
||||
return target_off;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -988,11 +988,11 @@ static int dtoverlay_get_target_offset(DTBLOB_T *base_dtb,
|
||||
if (!target_prop)
|
||||
{
|
||||
dtoverlay_error("no target or target-path");
|
||||
return NON_FATAL(len);
|
||||
return len;
|
||||
}
|
||||
|
||||
if (len != 4)
|
||||
return NON_FATAL(FDT_ERR_BADSTRUCTURE);
|
||||
return -FDT_ERR_BADSTRUCTURE;
|
||||
|
||||
phandle = fdt32_to_cpu(*(fdt32_t *)target_prop);
|
||||
if (!base_dtb)
|
||||
@@ -1007,7 +1007,7 @@ static int dtoverlay_get_target_offset(DTBLOB_T *base_dtb,
|
||||
if (target_off < 0)
|
||||
{
|
||||
dtoverlay_error("invalid target (phandle %d)", phandle);
|
||||
return NON_FATAL(target_off);
|
||||
return target_off;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1071,7 +1071,7 @@ static int dtoverlay_apply_overlay_paths(DTBLOB_T *base_dtb, int strings_off,
|
||||
target_off = dtoverlay_get_target_offset(base_dtb, overlay_dtb,
|
||||
sym_frag_off);
|
||||
if (target_off < 0)
|
||||
return target_off;
|
||||
return NON_FATAL(target_off);
|
||||
|
||||
err = fdt_get_path(base_dtb->fdt, target_off,
|
||||
target_path, sizeof(target_path));
|
||||
@@ -1239,7 +1239,7 @@ int dtoverlay_merge_overlay(DTBLOB_T *base_dtb, DTBLOB_T *overlay_dtb)
|
||||
target_off = dtoverlay_get_target_offset(base_dtb, overlay_dtb, frag_off);
|
||||
if (target_off < 0)
|
||||
{
|
||||
err = target_off;
|
||||
err = NON_FATAL(target_off);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user