Author: cgutman
Date: Sat May 30 21:12:45 2009
New Revision: 41207
URL:
http://svn.reactos.org/svn/reactos?rev=41207&view=rev
Log:
- Fix handling of nonpaged contiguous memory in NdisAllocateMemory and NdisFreeMemory
Modified:
trunk/reactos/drivers/network/ndis/ndis/memory.c
Modified: trunk/reactos/drivers/network/ndis/ndis/memory.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/ndis/ndis/…
==============================================================================
--- trunk/reactos/drivers/network/ndis/ndis/memory.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/ndis/ndis/memory.c [iso-8859-1] Sat May 30 21:12:45
2009
@@ -74,26 +74,26 @@
{
NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
- if (MemoryFlags & NDIS_MEMORY_NONCACHED)
- {
+ if (MemoryFlags & NDIS_MEMORY_CONTIGUOUS)
+ {
+ /* Allocate contiguous memory (possibly noncached) */
+ *VirtualAddress = MmAllocateContiguousMemorySpecifyCache(Length,
+
RtlConvertUlongToLargeInteger(0),
+ HighestAcceptableAddress,
+
RtlConvertUlongToLargeInteger(0),
+ (MemoryFlags &
NDIS_MEMORY_NONCACHED) ? MmNonCached : MmCached);
+ }
+ else if (MemoryFlags & NDIS_MEMORY_NONCACHED)
+ {
+ /* Allocate noncached noncontiguous memory */
*VirtualAddress = MmAllocateNonCachedMemory(Length);
- if(!*VirtualAddress)
- return NDIS_STATUS_FAILURE;
-
- return NDIS_STATUS_SUCCESS;
- }
-
- if (MemoryFlags & NDIS_MEMORY_CONTIGUOUS)
- {
- *VirtualAddress = MmAllocateContiguousMemory(Length, HighestAcceptableAddress);
- if(!*VirtualAddress)
- return NDIS_STATUS_FAILURE;
-
- return NDIS_STATUS_SUCCESS;
- }
-
- /* Plain nonpaged memory */
- *VirtualAddress = ExAllocatePool(NonPagedPool, Length);
+ }
+ else
+ {
+ /* Allocate plain nonpaged memory */
+ *VirtualAddress = ExAllocatePool(NonPagedPool, Length);
+ }
+
if (!*VirtualAddress)
return NDIS_STATUS_FAILURE;
@@ -120,19 +120,23 @@
{
NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
- if (MemoryFlags & NDIS_MEMORY_NONCACHED)
- {
+ if (MemoryFlags & NDIS_MEMORY_CONTIGUOUS)
+ {
+ /* Free contiguous memory (possibly noncached) */
+ MmFreeContiguousMemorySpecifyCache(VirtualAddress,
+ Length,
+ (MemoryFlags & NDIS_MEMORY_NONCACHED) ?
MmNonCached : MmCached);
+ }
+ else if (MemoryFlags & NDIS_MEMORY_NONCACHED)
+ {
+ /* Free noncached noncontiguous memory */
MmFreeNonCachedMemory(VirtualAddress, Length);
- return;
- }
-
- if (MemoryFlags & NDIS_MEMORY_CONTIGUOUS)
- {
- MmFreeContiguousMemory(VirtualAddress);
- return;
- }
-
- ExFreePool(VirtualAddress);
+ }
+ else
+ {
+ /* Free nonpaged pool */
+ ExFreePool(VirtualAddress);
+ }
}