Fix a bug in free_page.
authorcoderain <coderain@sdf.org>
Sat, 8 Sep 2018 18:06:27 +0000 (20:06 +0200)
committercoderain <coderain@sdf.org>
Sat, 8 Sep 2018 18:06:27 +0000 (20:06 +0200)
kernel/src/memory/memory.c

index 6a6f0ab66d41a734b42d8da23b7ddcd88db84e22..4d0798ac23b1819412aaa9dbdb58ec7be38f007b 100644 (file)
@@ -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;
 }