X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;ds=inline;f=KernelLand%2FModules%2FFilesystems%2FExt2%2Fdir.c;fp=KernelLand%2FModules%2FFilesystems%2FExt2%2Fdir.c;h=a0a5f146e76fa09c6538057477eca816f343fda4;hb=cbe0bf8833612d7581e96a55681fc576202d2969;hp=2f2b72f67267070779a2f5ad0bb3f64fb29bbc69;hpb=5e100f796b2bb499dddc4dfe5921e9972829c1ec;p=tpg%2Facess2.git diff --git a/KernelLand/Modules/Filesystems/Ext2/dir.c b/KernelLand/Modules/Filesystems/Ext2/dir.c index 2f2b72f6..a0a5f146 100644 --- a/KernelLand/Modules/Filesystems/Ext2/dir.c +++ b/KernelLand/Modules/Filesystems/Ext2/dir.c @@ -237,7 +237,6 @@ int Ext2_Link(tVFS_Node *Node, const char *Name, tVFS_Node *Child) Uint64 base; // Block's Base Address int block = 0, ofs = 0; Uint size; - void *blockData; int bestMatch = -1; int bestSize=0, bestBlock=0, bestOfs=0, bestNeedsSplit=0; int nEntries; @@ -245,7 +244,7 @@ int Ext2_Link(tVFS_Node *Node, const char *Name, tVFS_Node *Child) ENTER("pNode sName pChild", Node, Name, Child); - blockData = malloc(disk->BlockSize); + void *blockData = malloc(disk->BlockSize); // Read child inode (get's the file type) Ext2_int_ReadInode(disk, Child->Inode, &inode); @@ -306,9 +305,7 @@ int Ext2_Link(tVFS_Node *Node, const char *Name, tVFS_Node *Child) LOG(" name='%.*s'", dirent->name_len, dirent->name); if(strncmp(Name, dirent->name, dirent->name_len) == 0) { //Ext2_int_UnlockInode(disk, Node->Inode); - Mutex_Release(&Node->Lock); - LEAVE('i', 1); - return 1; // ERR_??? + goto _err; } int spare_space = dirent->rec_len - (dirent->name_len + EXT2_DIRENT_SIZE); @@ -393,8 +390,14 @@ int Ext2_Link(tVFS_Node *Node, const char *Name, tVFS_Node *Child) Child->Flags |= VFS_FFLAG_DIRTY; //Ext2_int_UnlockInode(disk, Node->Inode); + free(blockData); Mutex_Release(&Node->Lock); LEAVE('i', 0); return 0; +_err: + free(blockData); + Mutex_Release(&Node->Lock); + LEAVE('i', 1); + return 1; // ERR_??? }