Source-Changes-HG archive

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

[src/netbsd-1-5]: src/sys/kern Pull up revisions 1.43, 1.45 (requested by bouy...



details:   https://anonhg.NetBSD.org/src/rev/a842bda92f96
branches:  netbsd-1-5
changeset: 492761:a842bda92f96
user:      he <he%NetBSD.org@localhost>
date:      Sun Feb 10 14:12:10 2002 +0000

description:
Pull up revisions 1.43,1.45 (requested by bouyer):
  Two fixes:
   o Make sure that extent_alloc_subregion() does not allocate a region
     past the end of a subregion.
   o Avoid allocating a region over an already-allocated one when
     boundary is non-null.

diffstat:

 sys/kern/subr_extent.c |  24 ++++++++++++++++++++----
 1 files changed, 20 insertions(+), 4 deletions(-)

diffs (73 lines):

diff -r 224bdfbd6af5 -r a842bda92f96 sys/kern/subr_extent.c
--- a/sys/kern/subr_extent.c    Sun Feb 10 14:07:07 2002 +0000
+++ b/sys/kern/subr_extent.c    Sun Feb 10 14:12:10 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: subr_extent.c,v 1.32.2.2 2001/06/10 18:56:03 he Exp $  */
+/*     $NetBSD: subr_extent.c,v 1.32.2.3 2002/02/10 14:12:10 he Exp $  */
 
 /*-
  * Copyright (c) 1996, 1998 The NetBSD Foundation, Inc.
@@ -524,7 +524,7 @@
        u_long *result;
 {
        struct extent_region *rp, *myrp, *last, *bestlast;
-       u_long newstart, newend, beststart, bestovh, ovh;
+       u_long newstart, newend, exend, beststart, bestovh, ovh;
        u_long dontcross;
        int error;
 
@@ -605,6 +605,12 @@
        bestlast = NULL;
 
        /*
+        * Keep track of end of free region.  This is either the end of extent
+        * or the start of a region past the subend.
+        */
+       exend = ex->ex_end;
+
+       /*
         * For N allocated regions, we must make (N + 1)
         * checks for unallocated space.  The first chunk we
         * check is the area from the beginning of the subregion
@@ -647,6 +653,15 @@
 
        for (; rp != NULL; rp = rp->er_link.le_next) {
                /*
+                * If the region pasts the subend, bail out and see
+                * if we fit against the subend.
+                */
+               if (rp->er_start >= subend) {
+                       exend = rp->er_start;
+                       break;
+               }
+
+               /*
                 * Check the chunk before "rp".  Note that our
                 * comparison is safe from overflow conditions.
                 */
@@ -686,7 +701,7 @@
                                        newend = newstart + (size - 1);
                                        dontcross += boundary;
                                        if (!LE_OV(newstart, size, rp->er_start))
-                                               continue;
+                                               goto skip;
                                }
 
                                /*
@@ -721,6 +736,7 @@
                        }
                }
 
+skip:
                /*
                 * Skip past the current region and check again.
                 */
@@ -800,7 +816,7 @@
                 * fit, or we're taking the first fit, insert
                 * ourselves into the region list.
                 */
-               ovh = ex->ex_end - newstart - (size - 1);
+               ovh = exend - newstart - (size - 1);
                if ((flags & EX_FAST) || (ovh == 0))
                        goto found;
 



Home | Main Index | Thread Index | Old Index