Source-Changes-HG archive

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

[src/trunk]: src/sys/uvm Properly free "newppref", instead of "amap->am_ppref...



details:   https://anonhg.NetBSD.org/src/rev/649b38beca1d
branches:  trunk
changeset: 539360:649b38beca1d
user:      atatat <atatat%NetBSD.org@localhost>
date:      Fri Nov 15 17:30:35 2002 +0000

description:
Properly free "newppref", instead of "amap->am_ppref" (oops), and
delay freeing the old am_ppref so that if we bail early due to
malloc() failures, valid ppref data hasn't been freed for no reason.

Based on comments from enami.

diffstat:

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

diffs (53 lines):

diff -r c2d062b42b23 -r 649b38beca1d sys/uvm/uvm_amap.c
--- a/sys/uvm/uvm_amap.c        Fri Nov 15 16:15:20 2002 +0000
+++ b/sys/uvm/uvm_amap.c        Fri Nov 15 17:30:35 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvm_amap.c,v 1.46 2002/11/14 17:58:49 atatat Exp $     */
+/*     $NetBSD: uvm_amap.c,v 1.47 2002/11/15 17:30:35 atatat Exp $     */
 
 /*
  *
@@ -42,7 +42,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_amap.c,v 1.46 2002/11/14 17:58:49 atatat Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_amap.c,v 1.47 2002/11/15 17:30:35 atatat Exp $");
 
 #undef UVM_AMAP_INLINE         /* enable/disable amap inlines */
 
@@ -460,14 +460,9 @@
        slotalloc = malloc_roundup(slotneed * sizeof(int)) / sizeof(int);
 #ifdef UVM_AMAP_PPREF
        newppref = NULL;
-       if (amap->am_ppref && amap->am_ppref != PPREF_NONE) {
+       if (amap->am_ppref && amap->am_ppref != PPREF_NONE)
                newppref = malloc(slotalloc * sizeof(int), M_UVMAMAP,
                    M_WAITOK | M_CANFAIL);
-               if (newppref == NULL) {
-                       free(amap->am_ppref, M_UVMAMAP);
-                       amap->am_ppref = PPREF_NONE;
-               }
-       }
 #endif
        newsl = malloc(slotalloc * sizeof(int), M_UVMAMAP,
            M_WAITOK | M_CANFAIL);
@@ -478,7 +473,7 @@
        if (newsl == NULL || newbck == NULL || newover == NULL) {
 #ifdef UVM_AMAP_PPREF
                if (newppref != NULL) {
-                       free(amap->am_ppref, M_UVMAMAP);
+                       free(newppref, M_UVMAMAP);
                }
 #endif
                if (newsl != NULL) {
@@ -562,6 +557,9 @@
                        pp_setreflen(newppref, slotalloc - slotneed, 1,
                            slotneed - slotmapped);
                }
+       } else {
+               if (amap->am_ppref)
+                       amap->am_ppref = PPREF_NONE;
        }
 #endif
 



Home | Main Index | Thread Index | Old Index