mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 05:18:08 +02:00
rusticl: check the returned pointer of mmap
Prior Linux 4.17 MAP_FIXED_NOREPLACE might not be respected and might
return a pointer different than the requested one.
Fixes: da4de8d7e3 ("rusticl: add support for coarse-grain buffer SVM")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35286>
This commit is contained in:
parent
9b28067b59
commit
fa94b1b29c
1 changed files with 9 additions and 1 deletions
|
|
@ -319,7 +319,7 @@ impl Context {
|
|||
unreachable!("SVM supported only on Linux")
|
||||
}
|
||||
|
||||
let res = unsafe {
|
||||
let mut res = unsafe {
|
||||
mmap(
|
||||
vma.get() as usize as *mut c_void,
|
||||
size.get() as usize,
|
||||
|
|
@ -335,6 +335,14 @@ impl Context {
|
|||
return Err(CL_OUT_OF_HOST_MEMORY);
|
||||
}
|
||||
|
||||
if res as usize != vma.get() as usize {
|
||||
unsafe {
|
||||
let ret = munmap(res, size.get() as usize);
|
||||
debug_assert_eq!(0, ret);
|
||||
}
|
||||
res = ptr::null_mut();
|
||||
}
|
||||
|
||||
res.cast()
|
||||
} else {
|
||||
unsafe { alloc::alloc(layout) }.cast()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue