summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--boot/fdt_support.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/boot/fdt_support.c b/boot/fdt_support.c
index c4d3cc043c5..2941df55996 100644
--- a/boot/fdt_support.c
+++ b/boot/fdt_support.c
@@ -160,6 +160,12 @@ static int fdt_fixup_stdout(void *fdt, int chosenoff)
goto noalias;
}
+ if (len > (int)sizeof(tmp)) {
+ debug("%s: %s alias path too long (%d bytes)\n",
+ __func__, sername, len);
+ return -FDT_ERR_NOSPACE;
+ }
+
/* fdt_setprop may break "path" so we copy it to tmp buffer */
memcpy(tmp, path, len);
@@ -1627,6 +1633,13 @@ int fdt_get_dma_range(const void *blob, int node, phys_addr_t *cpu,
goto out;
}
+ if (len < (int)((na + pna + ns) * sizeof(*ranges))) {
+ debug("%s: dma-ranges too short for %s\n", __func__,
+ fdt_get_name(blob, node, NULL));
+ ret = -EINVAL;
+ goto out;
+ }
+
*bus = fdt_read_number(ranges, na);
*cpu = fdt_translate_dma_address(blob, node, ranges + na);
*size = fdt_read_number(ranges + na + pna, ns);