DMAResource: Validate that alignment <= block_size.

The code here cannot handle the case where alignment > block_size,
so anything calling Init() with these parameters is invalid.

Fixes #15902 (nvme_disk was long since adjusted, so this is a defense
against code being written in the future.)
This commit is contained in:
Augustin Cavalier 2020-06-20 14:54:49 -04:00
parent 5f9ca54d1a
commit 0786d50332

View File

@ -158,6 +158,8 @@ status_t
DMAResource::Init(const dma_restrictions& restrictions,
generic_size_t blockSize, uint32 bufferCount, uint32 bounceBufferCount)
{
ASSERT(restrictions.alignment <= blockSize);
fRestrictions = restrictions;
fBlockSize = blockSize == 0 ? 1 : blockSize;
fBufferCount = bufferCount;