kernel/device_manager: Add some missing checks in DMAResource::TranslateNext.

* Ensure memory is locked before doing virtual->physical translation.

 * Make sure get_memory_map_etc actually returned an entry.

I didn't see either of these trip in some basic testing though.
This commit is contained in:
Augustin Cavalier
2026-06-22 14:51:27 -04:00
parent 7bee547af0
commit 22d9a23207
@@ -437,6 +437,8 @@ DMAResource::TranslateNext(IORequest* request, IOOperation* operation,
offset, request->RemainingBytes(), fBlockSize, partialBegin);
if (buffer->IsVirtual()) {
ASSERT(buffer->IsMemoryLocked());
// Unless we need the bounce buffer anyway, we have to translate the
// virtual addresses to physical addresses, so we can check the DMA
// restrictions.
@@ -460,8 +462,10 @@ DMAResource::TranslateNext(IORequest* request, IOOperation* operation,
< fRestrictions.max_segment_count) {
physical_entry entry;
uint32 count = 1;
get_memory_map_etc(request->TeamID(), (void*)base, size,
&entry, &count);
get_memory_map_etc(request->TeamID(),
(void*)base, size, &entry, &count);
if (count != 1)
return B_ERROR;
vecs[segmentCount].base = entry.address;
vecs[segmentCount].length = entry.size;