Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/arm/arm32 In pmap_allocpagedir(), check if uvm_km_z...



details:   https://anonhg.NetBSD.org/src/rev/84837a809baf
branches:  trunk
changeset: 508840:84837a809baf
user:      toshii <toshii%NetBSD.org@localhost>
date:      Fri Apr 20 18:11:53 2001 +0000

description:
In pmap_allocpagedir(), check if uvm_km_zalloc of ptpt is successful,
and handle alloc failure case.

diffstat:

 sys/arch/arm/arm32/pmap.c |  11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diffs (39 lines):

diff -r 97f8a7268ec2 -r 84837a809baf sys/arch/arm/arm32/pmap.c
--- a/sys/arch/arm/arm32/pmap.c Fri Apr 20 18:08:48 2001 +0000
+++ b/sys/arch/arm/arm32/pmap.c Fri Apr 20 18:11:53 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap.c,v 1.4 2001/03/15 06:10:35 chs Exp $     */
+/*     $NetBSD: pmap.c,v 1.5 2001/04/20 18:11:53 toshii Exp $  */
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -178,6 +178,7 @@
     paddr_t pa, unsigned int flags));
 void pmap_copy_on_write __P((paddr_t pa));
 void pmap_pinit __P((pmap_t));
+void pmap_freepagedir __P((pmap_t));
 void pmap_release __P((pmap_t));
 
 /* Other function prototypes */
@@ -1085,6 +1086,11 @@
        }
 #endif /* DIAGNOSTIC */
        pmap->pm_vptpt = uvm_km_zalloc(kernel_map, NBPG);
+       if (pmap->pm_vptpt == 0) {
+               pmap_freepagedir(pmap);
+               return(ENOMEM);
+       }
+
        (void) pmap_extract(kernel_pmap, pmap->pm_vptpt, &pmap->pm_pptpt);
        pmap->pm_pptpt &= PG_FRAME;
        /* Revoke cacheability and bufferability */
@@ -1160,7 +1166,8 @@
        pmap_t pmap;
 {
        /* Free the memory used for the page table mapping */
-       uvm_km_free(kernel_map, (vaddr_t)pmap->pm_vptpt, NBPG);
+       if (pmap->pm_vptpt != 0)
+               uvm_km_free(kernel_map, (vaddr_t)pmap->pm_vptpt, NBPG);
 
        /* junk the L1 page table */
        if (pmap->pm_l1pt->pt_flags & PTFLAG_STATIC) {



Home | Main Index | Thread Index | Old Index