@@ -676,7 +676,8 @@ static int dtoverlay_phandle_relocate(DTBLOB_T *dtb, int node_off,
676
676
677
677
// Returns 0 on success, or an FDT error code
678
678
static int dtoverlay_apply_fixups (DTBLOB_T * dtb , const char * fixups_stringlist ,
679
- uint32_t phandle , fixup_type_t type )
679
+ int fixups_len , uint32_t phandle ,
680
+ fixup_type_t type )
680
681
{
681
682
// The fixups arrive as a sequence of NUL-terminated strings, of the form:
682
683
// "path:property:offset"
@@ -687,8 +688,9 @@ static int dtoverlay_apply_fixups(DTBLOB_T *dtb, const char *fixups_stringlist,
687
688
// 4) the code is simpler as a result.
688
689
689
690
const char * fixup = fixups_stringlist ;
691
+ const char * end = fixup + fixups_len ;
690
692
691
- while (fixup [0 ])
693
+ while (fixup < end && fixup [0 ])
692
694
{
693
695
const char * prop_name , * offset_str ;
694
696
char * offset_end ;
@@ -853,7 +855,7 @@ static int dtoverlay_resolve_phandles(DTBLOB_T *base_dtb, DTBLOB_T *overlay_dtb)
853
855
if (fixups_stringlist )
854
856
{
855
857
// Relocate the overlay phandle references
856
- err = dtoverlay_apply_fixups (overlay_dtb , fixups_stringlist ,
858
+ err = dtoverlay_apply_fixups (overlay_dtb , fixups_stringlist , err ,
857
859
base_dtb -> max_phandle , FIXUP_RELATIVE );
858
860
}
859
861
else
@@ -906,7 +908,7 @@ static int dtoverlay_resolve_fixups(DTBLOB_T *base_dtb, DTBLOB_T *overlay_dtb)
906
908
{
907
909
const char * fixups_stringlist , * symbol_name , * target_path ;
908
910
const char * ref_type ;
909
- int target_off ;
911
+ int target_off , fixups_len ;
910
912
uint32_t target_phandle ;
911
913
912
914
// The property name identifies a symbol (or alias) in the base.
@@ -920,6 +922,8 @@ static int dtoverlay_resolve_fixups(DTBLOB_T *base_dtb, DTBLOB_T *overlay_dtb)
920
922
break ;
921
923
}
922
924
925
+ fixups_len = err ;
926
+
923
927
// 1) Find the target node.
924
928
if (symbol_name [0 ] == '/' )
925
929
{
@@ -973,10 +977,13 @@ static int dtoverlay_resolve_fixups(DTBLOB_T *base_dtb, DTBLOB_T *overlay_dtb)
973
977
974
978
// Now apply the valid target_phandle to the items in the fixup string
975
979
976
- err = dtoverlay_apply_fixups (overlay_dtb , fixups_stringlist ,
980
+ err = dtoverlay_apply_fixups (overlay_dtb , fixups_stringlist , fixups_len ,
977
981
target_phandle , FIXUP_ABSOLUTE );
978
982
if (err )
983
+ {
984
+ dtoverlay_error ("failed to apply fixups" );
979
985
break ;
986
+ }
980
987
}
981
988
}
982
989
@@ -2343,9 +2350,11 @@ static const char *dtoverlay_extract_immediate(const char *data, const char *dat
2343
2350
return NULL ;
2344
2351
}
2345
2352
val = dtoverlay_read_u32 (data , 0 );
2346
- cell_source = data ;
2347
2353
if (buf )
2354
+ {
2355
+ cell_source = data ;
2348
2356
snprintf (buf , buf_len , "%d" , val );
2357
+ }
2349
2358
data += 4 ;
2350
2359
}
2351
2360
else if (data [0 ] == '\'' )
0 commit comments