X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=KernelLand%2FModules%2FStorage%2FLVM%2Fvolumes.c;h=cf1a60d16307e9f1932440438d0f076fd71a241f;hb=d69e48450c7ea4be4a82c351b2d5dd0de3fc6241;hp=fafa1f3d2d3df365d1dd92369f6ade545f24a1a9;hpb=695800da5d26cd12d5dfa0a93d0ef1eed0533c78;p=tpg%2Facess2.git diff --git a/KernelLand/Modules/Storage/LVM/volumes.c b/KernelLand/Modules/Storage/LVM/volumes.c index fafa1f3d..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 @@ -52,6 +62,7 @@ int LVM_AddVolume(const tLVM_VolType *Type, const char *Name, void *Ptr, size_t real_vol->Next = NULL; real_vol->Type = Type; real_vol->Ptr = Ptr; + real_vol->BlockSize = BlockSize; real_vol->BlockCount = BlockCount; real_vol->nSubVolumes = dummy_vol.nSubVolumes; real_vol->SubVolumes = (void*)( real_vol->Name + strlen(Name) + 1 );