kernel: mmu: Fix possible null de-reference

virt_page_phys_get can be called with phy parameter NULL when
the intention is just checking if a virtual address is mapped.

This function is generally overwritten by a an arch API that checks if
phys is null before using it but this default implementation doesn't.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
This commit is contained in:
Flavio Ceolin 2023-10-26 22:28:11 +00:00 committed by Anas Nashif
parent 471cff50e8
commit a36c016dff

View file

@ -469,7 +469,9 @@ static int virt_to_page_frame(void *virt, uintptr_t *phys)
if (z_page_frame_is_mapped(pf)) {
if (virt == pf->addr) {
ret = 0;
*phys = z_page_frame_to_phys(pf);
if (phys != NULL) {
*phys = z_page_frame_to_phys(pf);
}
break;
}
}