X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;ds=sidebyside;f=KernelLand%2FModules%2FStorage%2FLVM%2Fvolumes.c;h=cf1a60d16307e9f1932440438d0f076fd71a241f;hb=be5123fe1f4aa66b76ce8ef589362ad21b6bbf72;hp=f15b1b0a1effe4261966b1e0aa43eec8fc38aaa1;hpb=25b02822ad95feb8f82f7b8fef44a58e29afb79b;p=tpg%2Facess2.git diff --git a/KernelLand/Modules/Storage/LVM/volumes.c b/KernelLand/Modules/Storage/LVM/volumes.c index f15b1b0a..cf1a60d1 100644 --- a/KernelLand/Modules/Storage/LVM/volumes.c +++ b/KernelLand/Modules/Storage/LVM/volumes.c @@ -30,6 +30,12 @@ int LVM_AddVolume(const tLVM_VolType *Type, const char *Name, void *Ptr, size_t tLVM_Format *fmt; void *first_block; + if( BlockCount == 0 || BlockSize == 0 ) { + Log_Error("LVM", "BlockSize(0x%x)/BlockCount(0x%x) invalid in LVM_AddVolume", + BlockSize, BlockCount); + return 1; + } + dummy_vol.Type = Type; dummy_vol.Ptr = Ptr; dummy_vol.BlockCount = BlockCount; @@ -37,6 +43,10 @@ int LVM_AddVolume(const tLVM_VolType *Type, const char *Name, void *Ptr, size_t // Read the first block of the volume first_block = malloc(BlockSize); + if( !first_block ) { + Log_Error("VLM", "LVM_AddVolume - malloc error on %i bytes", BlockSize); + return -1; + } Type->Read(Ptr, 0, 1, first_block); // Determine Format @@ -56,6 +66,7 @@ int LVM_AddVolume(const tLVM_VolType *Type, const char *Name, void *Ptr, size_t real_vol->BlockCount = BlockCount; real_vol->nSubVolumes = dummy_vol.nSubVolumes; real_vol->SubVolumes = (void*)( real_vol->Name + strlen(Name) + 1 ); + real_vol->BlockSize = BlockSize; strcpy(real_vol->Name, Name); memset(real_vol->SubVolumes, 0, sizeof(tLVM_SubVolume*) * real_vol->nSubVolumes); // - VFS Nodes