Source-Changes-HG archive

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

[src/trunk]: src/sys/kern Fix off-by-one bug which would cause a region at th...



details:   https://anonhg.NetBSD.org/src/rev/8c2cbe7cf3ca
branches:  trunk
changeset: 574867:8c2cbe7cf3ca
user:      bouyer <bouyer%NetBSD.org@localhost>
date:      Tue Mar 15 18:22:24 2005 +0000

description:
Fix off-by-one bug which would cause a region at the end of the extent
to be alloctated multiple times:
- we're allocating region of size 1
- there are holes in the extent, but all of size larger than 1
- there are 2 contigous allocations at the end of the extent, the last one
  being of size 1.
While there fix a DIAGNOSTIC check: to check that a region is inside the extent
we need to check start and end, not only start.

diffstat:

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

diffs (36 lines):

diff -r ad07d88e0fcd -r 8c2cbe7cf3ca sys/kern/subr_extent.c
--- a/sys/kern/subr_extent.c    Tue Mar 15 18:22:03 2005 +0000
+++ b/sys/kern/subr_extent.c    Tue Mar 15 18:22:24 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: subr_extent.c,v 1.50 2004/03/23 13:22:33 junyoung Exp $        */
+/*     $NetBSD: subr_extent.c,v 1.51 2005/03/15 18:22:24 bouyer Exp $  */
 
 /*-
  * Copyright (c) 1996, 1998 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_extent.c,v 1.50 2004/03/23 13:22:33 junyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_extent.c,v 1.51 2005/03/15 18:22:24 bouyer Exp $");
 
 #ifdef _KERNEL
 #include "opt_lockdebug.h"
@@ -677,7 +677,7 @@
                 * If the region pasts the subend, bail out and see
                 * if we fit against the subend.
                 */
-               if (rp->er_start >= subend) {
+               if (rp->er_start > subend) {
                        exend = rp->er_start;
                        break;
                }
@@ -923,7 +923,7 @@
         */
        if (ex == NULL)
                panic("extent_free: NULL extent");
-       if ((start < ex->ex_start) || (start > ex->ex_end)) {
+       if ((start < ex->ex_start) || (end > ex->ex_end)) {
                extent_print(ex);
                printf("extent_free: extent `%s', start 0x%lx, size 0x%lx\n",
                    ex->ex_name, start, size);



Home | Main Index | Thread Index | Old Index