Fixing a kernel #PF caused by an unitialised VFS method
authorJohn Hodge <[email protected]>
Sun, 20 Jun 2010 09:28:50 +0000 (17:28 +0800)
committerJohn Hodge <[email protected]>
Sun, 20 Jun 2010 09:28:50 +0000 (17:28 +0800)
Kernel/vfs/open.c
Modules/IPStack/main.c

index 04facc7..552276d 100644 (file)
@@ -652,6 +652,14 @@ void VFS_Close(int FD)
                return;
        }
        
+       #if VALIDATE_VFS_FUNCTIPONS
+       if(h->Node->Close && !MM_GetPhysAddr(h->Node->Close)) {
+               Log_Warning("VFS", "Node %p's ->Close method is invalid (%p)",
+                       h->Node, h->Node->Close);
+               return ;
+       }
+       #endif
+       
        if(h->Node->Close)
                h->Node->Close( h->Node );
        
index 6b75b77..da7441c 100644 (file)
@@ -122,6 +122,11 @@ char *IPStack_Root_ReadDir(tVFS_Node *Node, int Pos)
        }
        
        name = malloc(4);
+       if(!name) {
+               Log_Warning("IPStack", "IPStack_Root_ReadDir - malloc error");
+               LEAVE('n');
+               return NULL;
+       }
        
        // Create the name
        Pos = iface->Node.ImplInt;
@@ -535,6 +540,10 @@ int IPStack_AddInterface(char *Device)
        iface->Node.ReadDir = IPStack_Iface_ReadDir;
        iface->Node.FindDir = IPStack_Iface_FindDir;
        iface->Node.IOCtl = IPStack_Iface_IOCtl;
+       iface->Node.MkNod = NULL;
+       iface->Node.Link = NULL;
+       iface->Node.Relink = NULL;
+       iface->Node.Close = NULL;
        
        // Set Defaults
        iface->TimeoutDelay = DEFAULT_TIMEOUT;

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