Kernel/x86 - mm_virt: Allowed PhysAddr=NULL with AllocDMA
authorJohn Hodge <[email protected]>
Fri, 26 Apr 2013 05:34:07 +0000 (13:34 +0800)
committerJohn Hodge <[email protected]>
Fri, 26 Apr 2013 05:34:07 +0000 (13:34 +0800)
KernelLand/Kernel/arch/x86/mm_virt.c

index e04b4ae..13562f2 100644 (file)
@@ -1080,7 +1080,7 @@ tVAddr MM_AllocDMA(int Pages, int MaxBits, tPAddr *PhysAddr)
                MaxBits = PHYS_BITS;
        
        // Sanity Check
-       if(MaxBits < 12 || !PhysAddr) {
+       if(MaxBits < 12) {
                LEAVE('i', 0);
                return 0;
        }
@@ -1089,11 +1089,11 @@ tVAddr MM_AllocDMA(int Pages, int MaxBits, tPAddr *PhysAddr)
        if(Pages == 1 && MaxBits >= PHYS_BITS)
        {
                phys = MM_AllocPhys();
+               if( PhysAddr )
+                       *PhysAddr = phys;
                if( !phys ) {
-                       *PhysAddr = 0;
                        LEAVE_RET('i', 0);
                }
-               *PhysAddr = phys;
                ret = MM_MapHWPages(phys, 1);
                if(ret == 0) {
                        MM_DerefPhys(phys);
@@ -1122,7 +1122,8 @@ tVAddr MM_AllocDMA(int Pages, int MaxBits, tPAddr *PhysAddr)
                return 0;
        }
        
-       *PhysAddr = phys;
+       if( PhysAddr )
+               *PhysAddr = phys;
        LEAVE('x', ret);
        return ret;
 }

UCC git Repository :: git.ucc.asn.au