Browse Source

Fix a bug in free_page.

coderain 7 months ago
parent
commit
46c61c61ea
1 changed files with 1 additions and 1 deletions
  1. 1 1
      kernel/src/memory/memory.c

+ 1 - 1
kernel/src/memory/memory.c

@@ -292,7 +292,7 @@ static inline dword_t free_page(void *virtual)
     unmap_page(virtual);
 
     page_t *page = get_page(phys);
-    if (page == NULL || page->ref_count == 0) free_physical_page(phys);
+    if (page != NULL && page->ref_count > 0) free_physical_page(phys);
 
     return ERR_SUCCESS;
 }