mirror of
https://github.com/dgibson/dtc.git
synced 2025-10-13 16:27:39 -04:00
Fix some potential unaligned accesses in dtc
Because of the convention of packed representations in property layouts, it's not uncommon to have integer values in properties which aren't naturally aligned. Thus, there are several places in the dtc code where we cast a potentially unaligned byte pointer into an integer pointer and load it directly. On a number of architectures (including sparc64 and arm) this won't work and will cause a fault. In some cases it may be trapped and emulated by the kernel, but not always. Therefore, replace such direct unaligned reads with a helper which will handle unaligned data reads (a variant on the fdtXX_ld() functions already used in libfdt). Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
parent
87a656ae5f
commit
b28464a550
4 changed files with 38 additions and 7 deletions
|
@ -110,13 +110,13 @@ static void write_propval_int(FILE *f, const char *p, size_t len, size_t width)
|
|||
fprintf(f, "%02"PRIx8, *(const uint8_t*)p);
|
||||
break;
|
||||
case 2:
|
||||
fprintf(f, "0x%02"PRIx16, fdt16_to_cpu(*(const fdt16_t*)p));
|
||||
fprintf(f, "0x%02"PRIx16, dtb_ld16(p));
|
||||
break;
|
||||
case 4:
|
||||
fprintf(f, "0x%02"PRIx32, fdt32_to_cpu(*(const fdt32_t*)p));
|
||||
fprintf(f, "0x%02"PRIx32, dtb_ld32(p));
|
||||
break;
|
||||
case 8:
|
||||
fprintf(f, "0x%02"PRIx64, fdt64_to_cpu(*(const fdt64_t*)p));
|
||||
fprintf(f, "0x%02"PRIx64, dtb_ld64(p));
|
||||
break;
|
||||
}
|
||||
if (p + width < end)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue