From: Ma Wupeng mawupeng1@huawei.com
hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I4SK3S CVE: NA
--------------------------------
Check whether page is NULL or not in page_reliable(). Return false if page is NULL.
Signed-off-by: Ma Wupeng mawupeng1@huawei.com Reviewed-by: Kefeng Wangwangkefeng.wang@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- include/linux/mem_reliable.h | 2 +- mm/mem_reliable.c | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/include/linux/mem_reliable.h b/include/linux/mem_reliable.h index c9c9b9aa8dfbb..00c915f583699 100644 --- a/include/linux/mem_reliable.h +++ b/include/linux/mem_reliable.h @@ -107,7 +107,7 @@ static inline void shmem_reliable_page_counter(struct page *page, int nr_page)
static inline void mem_reliable_buddy_counter(struct page *page, int nr_page) { - if (page && page_reliable(page)) + if (page_reliable(page)) this_cpu_add(nr_reliable_buddy_pages, nr_page); }
diff --git a/mm/mem_reliable.c b/mm/mem_reliable.c index 4aa6b83ca4a6b..ae4e9609f43cf 100644 --- a/mm/mem_reliable.c +++ b/mm/mem_reliable.c @@ -53,12 +53,15 @@ void add_reliable_mem_size(long sz)
bool page_reliable(struct page *page) { - return mem_reliable_is_enabled() && page_zonenum(page) < ZONE_MOVABLE; + if (!mem_reliable_is_enabled() || !page) + return false; + + return page_zonenum(page) < ZONE_MOVABLE; }
static bool reliable_and_lru_check(enum lru_list lru, struct page *page) { - if (!page || !page_reliable(page)) + if (!page_reliable(page)) return false;
if (lru != LRU_ACTIVE_FILE && lru != LRU_INACTIVE_FILE)