Subject: port-i386/13049: i386 may fail unlock map to head lock in pmap_enter
To: None <gnats-bugs@gnats.netbsd.org>
From: None <chris@paradox.demon.co.uk>
List: netbsd-bugs
Date: 05/27/2001 12:32:31
>Number:         13049
>Category:       port-i386
>Synopsis:       i386 pmap may not unlock one exit from pmap_enter
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    port-i386-maintainer
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Sun May 27 04:31:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     
>Release:        current - 27-05-01
>Organization:
>Environment:
	
System: NetBSD pinky.paradox.demon.co.uk 1.5U NetBSD 1.5U (PINKY) #4: Tue Apr 17 10:23:08 BST 2001 chris@pinky.paradox.demon.co.uk:/usr/obj/kern/PINKY i386
Architecture: i386
Machine: i386
>Description:
	Under low memory conditions pmap_enter may keep hold of the MAP_TO_HEAD_LOCK.
>How-To-Repeat:
	Examine pmap.c code, there's a return ENOMEM after the PMAP_MAP_TO_HEAD_LOCK() call.

>Fix:
	This diff should fix it (untested but looks the right thing :) :
ndex: pmap.c
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/i386/i386/pmap.c,v
retrieving revision 1.125
diff -u -p -r1.125 pmap.c
--- pmap.c      2001/05/26 16:32:41     1.125
+++ pmap.c      2001/05/27 11:30:12
@@ -2819,7 +2819,8 @@ pmap_enter(pmap, va, pa, prot, flags)
                ptp = pmap_get_ptp(pmap, pdei(va));
                if (ptp == NULL) {
                        if (flags & PMAP_CANFAIL) {
-                               return ENOMEM;
+                               error = ENOMEM;
+                               goto out;
                        }
                        panic("pmap_enter: get ptp failed");
                }
>Release-Note:
>Audit-Trail:
>Unformatted: