Module Name: src
Committed By: mlelstv
Date: Fri Jan 7 07:25:37 UTC 2022
Modified Files:
src/sys/dev/fdt: fdt_memory.c
Log Message:
Calculate the minimum address, don't assume the first entry is the start.
To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/fdt/fdt_memory.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/fdt/fdt_memory.c
diff -u src/sys/dev/fdt/fdt_memory.c:1.3 src/sys/dev/fdt/fdt_memory.c:1.4
--- src/sys/dev/fdt/fdt_memory.c:1.3 Sat Jun 26 10:43:52 2021
+++ src/sys/dev/fdt/fdt_memory.c Fri Jan 7 07:25:37 2022
@@ -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_
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;
}