From 4dd627b2a9a97dbb66c116cfa2aca2952fb34463 Mon Sep 17 00:00:00 2001 From: Pawel Wieczorkiewicz Date: Thu, 12 Aug 2021 15:17:53 +0200 Subject: [PATCH] pmm: check valid order parameter in put_free_frames() Add PAGE_ORDER_INVALID definition to flag invalid page order values. Signed-off-by: Pawel Wieczorkiewicz --- include/arch/x86/page.h | 3 ++- mm/pmm.c | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/include/arch/x86/page.h b/include/arch/x86/page.h index d393d949..c094b080 100644 --- a/include/arch/x86/page.h +++ b/include/arch/x86/page.h @@ -42,7 +42,8 @@ #define PAGE_MASK_1G (~(PAGE_SIZE_1G - 1)) #define PAGE_ORDER_1G 18 -#define MAX_PAGE_ORDER PAGE_ORDER_1G +#define MAX_PAGE_ORDER PAGE_ORDER_1G +#define PAGE_ORDER_INVALID (-1) #define _PAGE_PRESENT 0x0001 #define _PAGE_RW 0x0002 diff --git a/mm/pmm.c b/mm/pmm.c index 693c9399..37f58b73 100644 --- a/mm/pmm.c +++ b/mm/pmm.c @@ -210,7 +210,9 @@ void put_free_frames(mfn_t mfn, unsigned int order) { frame_t *frame; frame_t *found = NULL; - if (mfn == MFN_INVALID) + BUG_ON(mfn_invalid(mfn)); + + if (order > MAX_PAGE_ORDER) return; list_for_each_entry (frame, &busy_frames[order], list) {