Commit f0c71830 authored by Brian Geffon's avatar Brian Geffon Committed by Rafael J. Wysocki

PM: hibernate: Use __get_safe_page() rather than touching the list

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: default avatarBrian Geffon <bgeffon@google.com>
Fixes: 8357376d ("[PATCH] swsusp: Improve handling of highmem")
Cc: All applicable <stable@vger.kernel.org>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent ce9ecca0
...@@ -2545,8 +2545,9 @@ static void *get_highmem_page_buffer(struct page *page, ...@@ -2545,8 +2545,9 @@ static void *get_highmem_page_buffer(struct page *page,
pbe->copy_page = tmp; pbe->copy_page = tmp;
} else { } else {
/* Copy of the page will be stored in normal memory */ /* Copy of the page will be stored in normal memory */
kaddr = safe_pages_list; kaddr = __get_safe_page(ca->gfp_mask);
safe_pages_list = safe_pages_list->next; if (!kaddr)
return ERR_PTR(-ENOMEM);
pbe->copy_page = virt_to_page(kaddr); pbe->copy_page = virt_to_page(kaddr);
} }
pbe->next = highmem_pblist; pbe->next = highmem_pblist;
...@@ -2750,8 +2751,9 @@ static void *get_buffer(struct memory_bitmap *bm, struct chain_allocator *ca) ...@@ -2750,8 +2751,9 @@ static void *get_buffer(struct memory_bitmap *bm, struct chain_allocator *ca)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
} }
pbe->orig_address = page_address(page); pbe->orig_address = page_address(page);
pbe->address = safe_pages_list; pbe->address = __get_safe_page(ca->gfp_mask);
safe_pages_list = safe_pages_list->next; if (!pbe->address)
return ERR_PTR(-ENOMEM);
pbe->next = restore_pblist; pbe->next = restore_pblist;
restore_pblist = pbe; restore_pblist = pbe;
return pbe->address; return pbe->address;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment