mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-07 03:15:31 +09:00
MALI: utgard: fix mali_mmap failed
Validate vmf_insert_pfn return value with VM_FAULT_NOPAGE Signed-off-by: Jacob Chen <cc@rock-chips.com> Change-Id: I53b1eabd20ab76f08f5edf571ead1ffaccd19ec1
This commit is contained in:
@@ -534,8 +534,8 @@ int mali_mem_cow_cpu_map(mali_mem_backend *mem_bkend, struct vm_area_struct *vma
|
||||
*/
|
||||
ret = vmf_insert_pfn(vma, addr, _mali_page_node_get_pfn(m_page));
|
||||
|
||||
if (unlikely(0 != ret)) {
|
||||
return ret;
|
||||
if (unlikely(VM_FAULT_NOPAGE != ret)) {
|
||||
return -EFAULT;
|
||||
}
|
||||
addr += _MALI_OSK_MALI_PAGE_SIZE;
|
||||
}
|
||||
@@ -571,7 +571,7 @@ _mali_osk_errcode_t mali_mem_cow_cpu_map_pages_locked(mali_mem_backend *mem_bken
|
||||
if ((count >= offset) && (count < offset + num)) {
|
||||
ret = vmf_insert_pfn(vma, vaddr, _mali_page_node_get_pfn(m_page));
|
||||
|
||||
if (unlikely(0 != ret)) {
|
||||
if (unlikely(VM_FAULT_NOPAGE != ret)) {
|
||||
if (count == offset) {
|
||||
return _MALI_OSK_ERR_FAULT;
|
||||
} else {
|
||||
|
||||
@@ -592,7 +592,6 @@ failed_alloc_pages:
|
||||
failed_prepare_map:
|
||||
mali_mem_backend_struct_destory(&mem_backend, mali_allocation->backend_handle);
|
||||
failed_alloc_backend:
|
||||
|
||||
mali_vma_offset_remove(&session->allocation_mgr, &mali_allocation->mali_vma_node);
|
||||
mali_mem_allocation_struct_destory(mali_allocation);
|
||||
|
||||
|
||||
@@ -367,7 +367,7 @@ int mali_mem_os_cpu_map(mali_mem_backend *mem_bkend, struct vm_area_struct *vma)
|
||||
page = m_page->page;
|
||||
ret = vmf_insert_pfn(vma, addr, page_to_pfn(page));
|
||||
|
||||
if (unlikely(0 != ret)) {
|
||||
if (unlikely(VM_FAULT_NOPAGE != ret)) {
|
||||
return -EFAULT;
|
||||
}
|
||||
addr += _MALI_OSK_MALI_PAGE_SIZE;
|
||||
@@ -405,7 +405,7 @@ _mali_osk_errcode_t mali_mem_os_resize_cpu_map_locked(mali_mem_backend *mem_bken
|
||||
if (mapping_page_num > 0) {
|
||||
ret = vmf_insert_pfn(vma, vm_end, page_to_pfn(m_page->page));
|
||||
|
||||
if (unlikely(0 != ret)) {
|
||||
if (unlikely(VM_FAULT_NOPAGE != ret)) {
|
||||
/*will return -EBUSY If the page has already been mapped into table, but it's OK*/
|
||||
if (-EBUSY == ret) {
|
||||
break;
|
||||
@@ -428,7 +428,7 @@ _mali_osk_errcode_t mali_mem_os_resize_cpu_map_locked(mali_mem_backend *mem_bken
|
||||
|
||||
ret = vmf_insert_pfn(vma, vstart, page_to_pfn(m_page->page));
|
||||
|
||||
if (unlikely(0 != ret)) {
|
||||
if (unlikely(VM_FAULT_NOPAGE != ret)) {
|
||||
/*will return -EBUSY If the page has already been mapped into table, but it's OK*/
|
||||
if (-EBUSY == ret) {
|
||||
break;
|
||||
|
||||
@@ -131,7 +131,7 @@ int mali_mem_secure_cpu_map(mali_mem_backend *mem_bkend, struct vm_area_struct *
|
||||
for (j = 0; j < size / _MALI_OSK_MALI_PAGE_SIZE; j++) {
|
||||
ret = vmf_insert_pfn(vma, addr, PFN_DOWN(phys));
|
||||
|
||||
if (unlikely(0 != ret)) {
|
||||
if (unlikely(VM_FAULT_NOPAGE != ret)) {
|
||||
return -EFAULT;
|
||||
}
|
||||
addr += _MALI_OSK_MALI_PAGE_SIZE;
|
||||
|
||||
Reference in New Issue
Block a user