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:
@@ -437,6 +437,8 @@ DMAResource::TranslateNext(IORequest* request, IOOperation* operation,
|
|||||||
offset, request->RemainingBytes(), fBlockSize, partialBegin);
|
offset, request->RemainingBytes(), fBlockSize, partialBegin);
|
||||||
|
|
||||||
if (buffer->IsVirtual()) {
|
if (buffer->IsVirtual()) {
|
||||||
|
ASSERT(buffer->IsMemoryLocked());
|
||||||
|
|
||||||
// Unless we need the bounce buffer anyway, we have to translate the
|
// Unless we need the bounce buffer anyway, we have to translate the
|
||||||
// virtual addresses to physical addresses, so we can check the DMA
|
// virtual addresses to physical addresses, so we can check the DMA
|
||||||
// restrictions.
|
// restrictions.
|
||||||
@@ -460,8 +462,10 @@ DMAResource::TranslateNext(IORequest* request, IOOperation* operation,
|
|||||||
< fRestrictions.max_segment_count) {
|
< fRestrictions.max_segment_count) {
|
||||||
physical_entry entry;
|
physical_entry entry;
|
||||||
uint32 count = 1;
|
uint32 count = 1;
|
||||||
get_memory_map_etc(request->TeamID(), (void*)base, size,
|
get_memory_map_etc(request->TeamID(),
|
||||||
&entry, &count);
|
(void*)base, size, &entry, &count);
|
||||||
|
if (count != 1)
|
||||||
|
return B_ERROR;
|
||||||
|
|
||||||
vecs[segmentCount].base = entry.address;
|
vecs[segmentCount].base = entry.address;
|
||||||
vecs[segmentCount].length = entry.size;
|
vecs[segmentCount].length = entry.size;
|
||||||
|
|||||||
Reference in New Issue
Block a user