In the case of non-sequential mappings, ofw_mapmem() could ask Open
Firmware to map a memory region with negative length, causing crashes and Undefined Behavior. Add the appropriate check to make the behavior defined.
This commit is contained in:
parent
287cf3e528
commit
fa942e6074
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=212165
@ -68,7 +68,7 @@ ofw_mapmem(vm_offset_t dest, const size_t len)
|
||||
/*
|
||||
* Trim area covered by existing mapping, if any
|
||||
*/
|
||||
if (dest < (last_dest + last_len)) {
|
||||
if (dest < (last_dest + last_len) && dest >= last_dest) {
|
||||
nlen -= (last_dest + last_len) - dest;
|
||||
dest = last_dest + last_len;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user