diff --git a/ntoskrnl/mm/ARM3/pfnlist.c b/ntoskrnl/mm/ARM3/pfnlist.c index 56654d1e113..cf7871f2023 100644 --- a/ntoskrnl/mm/ARM3/pfnlist.c +++ b/ntoskrnl/mm/ARM3/pfnlist.c @@ -481,8 +481,11 @@ MiRemoveAnyPage(IN ULONG Color) /* Make sure PFN lock is held and we have pages */ MI_ASSERT_PFN_LOCK_HELD(); - ASSERT(MmAvailablePages != 0); ASSERT(Color < MmSecondaryColors); + if (MmAvailablePages == 0) + { + return 0; + } /* Check the colored free list */ PageIndex = MmFreePagesByColor[FreePageList][Color].Flink; @@ -514,6 +517,7 @@ MiRemoveAnyPage(IN ULONG Color) /* Remove the page from its list */ PageIndex = MiRemovePageByColor(PageIndex, Color); + ASSERT(PageIndex != 0); /* Sanity checks */ Pfn1 = MI_PFN_ELEMENT(PageIndex); @@ -538,8 +542,11 @@ MiRemoveZeroPage(IN ULONG Color) /* Make sure PFN lock is held and we have pages */ MI_ASSERT_PFN_LOCK_HELD(); - ASSERT(MmAvailablePages != 0); ASSERT(Color < MmSecondaryColors); + if (MmAvailablePages == 0) + { + return 0; + } /* Check the colored zero list */ PageIndex = MmFreePagesByColor[ZeroedPageList][Color].Flink; @@ -583,6 +590,7 @@ MiRemoveZeroPage(IN ULONG Color) /* Remove the page from its list */ PageIndex = MiRemovePageByColor(PageIndex, Color); + ASSERT(PageIndex != 0); ASSERT(Pfn1 == MI_PFN_ELEMENT(PageIndex)); /* Zero it, if needed */ diff --git a/ntoskrnl/mm/balance.c b/ntoskrnl/mm/balance.c index a8c9e4c6482..f81027a65cd 100644 --- a/ntoskrnl/mm/balance.c +++ b/ntoskrnl/mm/balance.c @@ -303,20 +303,21 @@ MmRequestPageMemoryConsumer(ULONG Consumer, BOOLEAN CanWait, { PFN_NUMBER Page; - /* Update the target */ - InterlockedIncrementUL(&MiMemoryConsumers[Consumer].PagesUsed); - UpdateTotalCommittedPages(1); - /* * Actually allocate the page. */ Page = MmAllocPage(Consumer); if (Page == 0) { - KeBugCheck(NO_PAGES_AVAILABLE); + *AllocatedPage = 0; + return STATUS_NO_MEMORY; } *AllocatedPage = Page; + /* Update the target */ + InterlockedIncrementUL(&MiMemoryConsumers[Consumer].PagesUsed); + UpdateTotalCommittedPages(1); + return(STATUS_SUCCESS); } diff --git a/ntoskrnl/mm/freelist.c b/ntoskrnl/mm/freelist.c index e3b2f30f9fa..95d73eb3cd4 100644 --- a/ntoskrnl/mm/freelist.c +++ b/ntoskrnl/mm/freelist.c @@ -623,7 +623,8 @@ MmAllocPage(ULONG Type) PfnOffset = MiRemoveZeroPage(MI_GET_NEXT_COLOR()); if (!PfnOffset) { - KeBugCheck(NO_PAGES_AVAILABLE); + MiReleasePfnLock(OldIrql); + return 0; } DPRINT("Legacy allocate: %lx\n", PfnOffset);