kernel/eka/memmodel/epoc/flexible/mmu/mobject.cpp
changeset 6 0173bcd7697c
parent 4 56f325a607ea
child 19 4a8fed1c0ef6
--- a/kernel/eka/memmodel/epoc/flexible/mmu/mobject.cpp	Wed Dec 23 11:43:31 2009 +0000
+++ b/kernel/eka/memmodel/epoc/flexible/mmu/mobject.cpp	Thu Jan 07 13:38:45 2010 +0200
@@ -648,19 +648,20 @@
 		if(pinnedPt && pinnedPt!=pt)
 			{
 			// previously pinned page table not needed...
-			PageTableAllocator::UnpinPageTable(pinnedPt,aPinArgs);
+			::PageTables.UnpinPageTable(pinnedPt,aPinArgs);
 
 			// make sure we have memory for next pin attempt...
 			MmuLock::Unlock();
 			aPinArgs.AllocReplacementPages(KNumPagesToPinOnePageTable);
-			MmuLock::Lock();
 			if(!aPinArgs.HaveSufficientPages(KNumPagesToPinOnePageTable)) // if out of memory...
 				{
 				// make sure we free any unneeded page table we allocated...
 				if(pt)
 					FreePageTable(aChunkIndex);
+				MmuLock::Lock();
 				return 0;
 				}
+			MmuLock::Lock();
 			}
 
 		if(!pt)
@@ -680,8 +681,16 @@
 			return pt;
 
 		// pin the page table...
+		if (::PageTables.PinPageTable(pt,aPinArgs) != KErrNone)
+			{
+			// Couldn't pin the page table...
+			MmuLock::Unlock();
+			// make sure we free any unneeded page table we allocated...
+			FreePageTable(aChunkIndex);
+			MmuLock::Lock();
+			return 0;
+			}
 		pinnedPt = pt;
-		PageTableAllocator::PinPageTable(pinnedPt,aPinArgs);
 		}
 	}