diff options
| author | mlelstv <mlelstv@NetBSD.org> | 2022-01-07 07:25:37 +0000 |
|---|---|---|
| committer | mlelstv <mlelstv@NetBSD.org> | 2022-01-07 07:25:37 +0000 |
| commit | a2ea75c071c121c093b22e86b00667aadaf0f688 (patch) | |
| tree | c912cbd6ba9f1c1ffa9bd6d702a684bd0d7cd712 /sys/dev | |
| parent | 1bbff15bb4835a9b20214b8878bc0357f41d6c8d (diff) | |
Calculate the minimum address, don't assume the first entry is the start.
Diffstat (limited to 'sys/dev')
| -rw-r--r-- | sys/dev/fdt/fdt_memory.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/sys/dev/fdt/fdt_memory.c b/sys/dev/fdt/fdt_memory.c index fb3c2f88d6b..2761f0f9717 100644 --- a/sys/dev/fdt/fdt_memory.c +++ b/sys/dev/fdt/fdt_memory.c @@ -1,4 +1,4 @@ -/* $NetBSD: fdt_memory.c,v 1.3 2021/06/26 10:43:52 jmcneill Exp $ */ +/* $NetBSD: fdt_memory.c,v 1.4 2022/01/07 07:25:37 mlelstv Exp $ */ /*- * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -32,7 +32,7 @@ #include "opt_fdt.h" #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: fdt_memory.c,v 1.3 2021/06/26 10:43:52 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fdt_memory.c,v 1.4 2022/01/07 07:25:37 mlelstv Exp $"); #include <sys/param.h> #include <sys/queue.h> @@ -90,12 +90,13 @@ fdt_memory_get(uint64_t *pstart, uint64_t *pend) index++) { fdt_memory_add_range(cur_addr, cur_size); - /* Assume the first entry is the start of memory */ if (index == 0) { *pstart = cur_addr; *pend = cur_addr + cur_size; continue; } + if (cur_addr < *pstart) + *pstart = cur_addr; if (cur_addr + cur_size > *pend) *pend = cur_addr + cur_size; } |
