Source-Changes-HG archive

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

[src/trunk]: src/sys/uvm fix bug in amap_wiperange() detected by enami tsugut...



details:   https://anonhg.NetBSD.org/src/rev/ebce817b6a66
branches:  trunk
changeset: 518547:ebce817b6a66
user:      chuck <chuck%NetBSD.org@localhost>
date:      Sat Dec 01 22:11:13 2001 +0000

description:
fix bug in amap_wiperange() detected by enami tsugutomo.
loop control was wrong in one case.

diffstat:

 sys/uvm/uvm_amap.c |  18 +++++++++++-------
 1 files changed, 11 insertions(+), 7 deletions(-)

diffs (55 lines):

diff -r 334d9b7175b9 -r ebce817b6a66 sys/uvm/uvm_amap.c
--- a/sys/uvm/uvm_amap.c        Sat Dec 01 21:23:17 2001 +0000
+++ b/sys/uvm/uvm_amap.c        Sat Dec 01 22:11:13 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvm_amap.c,v 1.37 2001/11/10 07:36:59 lukem Exp $      */
+/*     $NetBSD: uvm_amap.c,v 1.38 2001/12/01 22:11:13 chuck Exp $      */
 
 /*
  *
@@ -42,7 +42,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_amap.c,v 1.37 2001/11/10 07:36:59 lukem Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_amap.c,v 1.38 2001/12/01 22:11:13 chuck Exp $");
 
 #undef UVM_AMAP_INLINE         /* enable/disable amap inlines */
 
@@ -990,7 +990,7 @@
        struct vm_amap *amap;
        int slotoff, slots;
 {
-       int byanon, lcv, stop, curslot, ptr;
+       int byanon, lcv, stop, curslot, ptr, slotend;
        struct vm_anon *anon;
 
        /*
@@ -1006,19 +1006,23 @@
                byanon = FALSE;
                lcv = 0;
                stop = amap->am_nused;
+               slotend = slotoff + slots;
        }
 
-       for (; lcv < stop; lcv++) {
+       while (lcv < stop) {
                int refs;
 
                if (byanon) {
-                       if (amap->am_anon[lcv] == NULL)
+                       curslot = lcv++;        /* lcv advances here */
+                       if (amap->am_anon[curslot] == NULL)
                                continue;
-                       curslot = lcv;
                } else {
                        curslot = amap->am_slots[lcv];
-                       if (curslot < slotoff || curslot >= stop)
+                       if (curslot < slotoff || curslot >= slotend) {
+                               lcv++;          /* lcv advances here */
                                continue;
+                       }
+                       stop--; /* drop stop, since anon will be removed */
                }
                anon = amap->am_anon[curslot];
 



Home | Main Index | Thread Index | Old Index