pci: add safety comments

Signed-off-by: Wei Liu <liuwe@microsoft.com>
This commit is contained in:
Wei Liu 2022-11-16 22:20:42 +00:00 committed by Liu Wei
parent d1b9d9d7f7
commit c5bd8cabc4
2 changed files with 4 additions and 0 deletions

View File

@ -1422,6 +1422,7 @@ impl VfioPciDevice {
)?; )?;
for area in sparse_areas.iter() { for area in sparse_areas.iter() {
// SAFETY: FFI call with correct arguments
let host_addr = unsafe { let host_addr = unsafe {
libc::mmap( libc::mmap(
null_mut(), null_mut(),
@ -1488,6 +1489,7 @@ impl VfioPciDevice {
error!("Could not remove the userspace memory region: {}", e); error!("Could not remove the userspace memory region: {}", e);
} }
// SAFETY: FFI call with correct arguments
let ret = unsafe { let ret = unsafe {
libc::munmap( libc::munmap(
user_memory_region.host_addr as *mut libc::c_void, user_memory_region.host_addr as *mut libc::c_void,

View File

@ -181,6 +181,7 @@ impl VfioUserPciDevice {
}; };
for s in mmaps.iter() { for s in mmaps.iter() {
// SAFETY: FFI call with correct arguments
let host_addr = unsafe { let host_addr = unsafe {
libc::mmap( libc::mmap(
null_mut(), null_mut(),
@ -247,6 +248,7 @@ impl VfioUserPciDevice {
} }
// Remove mmaps // Remove mmaps
// SAFETY: FFI call with correct arguments
let ret = unsafe { let ret = unsafe {
libc::munmap( libc::munmap(
user_memory_region.host_addr as *mut libc::c_void, user_memory_region.host_addr as *mut libc::c_void,