From 0786d50332a868ba2e794efdd7cc7f052a356872 Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Sat, 20 Jun 2020 14:54:49 -0400 Subject: [PATCH] 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.) --- src/system/kernel/device_manager/dma_resources.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/system/kernel/device_manager/dma_resources.cpp b/src/system/kernel/device_manager/dma_resources.cpp index dfbaf80479..99d0d3a858 100644 --- a/src/system/kernel/device_manager/dma_resources.cpp +++ b/src/system/kernel/device_manager/dma_resources.cpp @@ -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;