summaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorBrian Geffon <bgeffon@google.com>2023-09-21 13:00:45 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-11-28 16:46:34 +0000
commitbda48834590b392db7ab635a9fa2882ece5a82c4 (patch)
tree4cf67486b929382cefa7247f78bc6e108cef01cf /kernel
parent562031121a3426e2a2d8053f5a2e7706f8fab483 (diff)
downloadlinux-stable-bda48834590b392db7ab635a9fa2882ece5a82c4.tar.gz
linux-stable-bda48834590b392db7ab635a9fa2882ece5a82c4.tar.bz2
linux-stable-bda48834590b392db7ab635a9fa2882ece5a82c4.zip
PM: hibernate: Use __get_safe_page() rather than touching the list
commit f0c7183008b41e92fa676406d87f18773724b48b upstream. We found at least one situation where the safe pages list was empty and get_buffer() would gladly try to use a NULL pointer. Signed-off-by: Brian Geffon <bgeffon@google.com> Fixes: 8357376d3df2 ("[PATCH] swsusp: Improve handling of highmem") Cc: All applicable <stable@vger.kernel.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/power/snapshot.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/kernel/power/snapshot.c b/kernel/power/snapshot.c
index f2635fc751d9..444a3db3819e 100644
--- a/kernel/power/snapshot.c
+++ b/kernel/power/snapshot.c
@@ -2376,8 +2376,9 @@ static void *get_highmem_page_buffer(struct page *page,
pbe->copy_page = tmp;
} else {
/* Copy of the page will be stored in normal memory */
- kaddr = safe_pages_list;
- safe_pages_list = safe_pages_list->next;
+ kaddr = __get_safe_page(ca->gfp_mask);
+ if (!kaddr)
+ return ERR_PTR(-ENOMEM);
pbe->copy_page = virt_to_page(kaddr);
}
pbe->next = highmem_pblist;
@@ -2557,8 +2558,9 @@ static void *get_buffer(struct memory_bitmap *bm, struct chain_allocator *ca)
return ERR_PTR(-ENOMEM);
}
pbe->orig_address = page_address(page);
- pbe->address = safe_pages_list;
- safe_pages_list = safe_pages_list->next;
+ pbe->address = __get_safe_page(ca->gfp_mask);
+ if (!pbe->address)
+ return ERR_PTR(-ENOMEM);
pbe->next = restore_pblist;
restore_pblist = pbe;
return pbe->address;