diff options
author | Federico G. Schwindt <fgsch@cvs.openbsd.org> | 1998-10-01 18:00:05 +0000 |
---|---|---|
committer | Federico G. Schwindt <fgsch@cvs.openbsd.org> | 1998-10-01 18:00:05 +0000 |
commit | 3377b22fe5c44cdb4cfcbae9c5ad171c66e10e77 (patch) | |
tree | 89529dd5fa30e197d51d50aa78d39b547c60e725 | |
parent | 0788a373ba5dd6046227d07ee5d02244f3ab0935 (diff) |
Fix a serious bug in extent_alloc_subregion where the subregion start
was ignored. This fix some problems in the pcmcia framework.
-rw-r--r-- | sys/kern/subr_extent.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/sys/kern/subr_extent.c b/sys/kern/subr_extent.c index 2e0a72b9282..e1172f15582 100644 --- a/sys/kern/subr_extent.c +++ b/sys/kern/subr_extent.c @@ -1,4 +1,4 @@ -/* $OpenBSD: subr_extent.c,v 1.4 1998/02/25 19:53:49 weingart Exp $ */ +/* $OpenBSD: subr_extent.c,v 1.5 1998/10/01 18:00:04 fgsch Exp $ */ /* $NetBSD: subr_extent.c,v 1.7 1996/11/21 18:46:34 cgd Exp $ */ /*- @@ -617,8 +617,27 @@ extent_alloc_subregion(ex, substart, subend, size, alignment, boundary, #endif } + /* + * Find the first allocated region that begins on or after + * the subregion start, advancing the "last" pointer along + * the way. + */ for (rp = ex->ex_regions.lh_first; rp != NULL; rp = rp->er_link.le_next) { + if (rp->er_start >= newstart) + break; + last = rp; + } + + /* + * If there are no allocated regions beyond where we want to be, + * relocate the start of our candidate region to the end of + * the last allocated region (if there was one). + */ + if (rp == NULL && last != NULL) + newstart = EXTENT_ALIGN((last->er_end + 1), alignment); + + for (; rp != NULL; rp = rp->er_link.le_next) { /* * Check the chunk before "rp". Note that our * comparison is safe from overflow conditions. |