Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/evbarm/fdt Fix partial overlap logic. PR# port-evba...



details:   https://anonhg.NetBSD.org/src/rev/b609840901fa
branches:  trunk
changeset: 445533:b609840901fa
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Thu Nov 01 10:21:41 2018 +0000

description:
Fix partial overlap logic. PR# port-evbarm/53693

diffstat:

 sys/arch/evbarm/fdt/fdt_memory.c |  19 +++++++++++--------
 1 files changed, 11 insertions(+), 8 deletions(-)

diffs (43 lines):

diff -r 8564690c0420 -r b609840901fa sys/arch/evbarm/fdt/fdt_memory.c
--- a/sys/arch/evbarm/fdt/fdt_memory.c  Thu Nov 01 05:37:11 2018 +0000
+++ b/sys/arch/evbarm/fdt/fdt_memory.c  Thu Nov 01 10:21:41 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fdt_memory.c,v 1.1 2018/10/30 21:32:35 jmcneill Exp $ */
+/* $NetBSD: fdt_memory.c,v 1.2 2018/11/01 10:21:41 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #include "opt_bootconfig.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fdt_memory.c,v 1.1 2018/10/30 21:32:35 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdt_memory.c,v 1.2 2018/11/01 10:21:41 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/queue.h>
@@ -147,15 +147,18 @@
                        next->mr_mem.end = mr->mr_mem.end;
                        mr->mr_mem.end = start;
                        TAILQ_INSERT_AFTER(&fdt_memory_ranges, mr, next, mr_list);
-               } else {
+               } else if (start <= mr->mr_mem.start && end < mr->mr_mem.end) {
                        /*
-                        * Partial overlap.
+                        * Partial overlap at the beginning of the range.
                         */
-                       if (start >= mr->mr_mem.start && start < mr->mr_mem.end)
-                               mr->mr_mem.end = start;
-                       if (end < mr->mr_mem.end && end > mr->mr_mem.start)
-                               mr->mr_mem.start = end;
+                       mr->mr_mem.start = end;
+               } else if (start > mr->mr_mem.start && end >= mr->mr_mem.end) {
+                       /*
+                        * Partial overlap at the end of the range.
+                        */
+                       mr->mr_mem.end = start;
                }
+               KASSERT(mr->mr_mem.start < mr->mr_mem.end);
        }
 }
 



Home | Main Index | Thread Index | Old Index