From: Brian Geffon <bgeffon@google.com>
To: "Rafael J . Wysocki" <rafael@kernel.org>
Cc: Pavel Machek <pavel@ucw.cz>, Len Brown <len.brown@intel.com>,
linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
Matthias Kaehlcke <mka@chromium.org>,
stable@vger.kernel.org, Brian Geffon <bgeffon@google.com>
Subject: [PATCH] PM: hibernate: use __get_safe_page() rather than touching the list.
Date: Thu, 21 Sep 2023 13:00:45 -0400 [thread overview]
Message-ID: <20230921170045.4189251-1-bgeffon@google.com> (raw)
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: 8357376 ("swsusp: Improve handling of highmem")
Cc: stable@vger.kernel.org
Change-Id: Ibb43a9b4ac5ff2d7e3021fdacc08e116650231e9
---
kernel/power/snapshot.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/kernel/power/snapshot.c b/kernel/power/snapshot.c
index 362e6bae5891..2dcb33248518 100644
--- a/kernel/power/snapshot.c
+++ b/kernel/power/snapshot.c
@@ -2544,8 +2544,9 @@ static void *get_highmem_page_buffer(struct page *page,
pbe->copy_page = pfn_to_page(pfn);
} 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;
@@ -2747,8 +2748,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;
--
2.42.0.459.ge4e396fd5e-goog
next reply other threads:[~2023-09-21 17:03 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-21 17:00 Brian Geffon [this message]
2023-09-21 18:26 ` [PATCH] PM: hibernate: use __get_safe_page() rather than touching the list Rafael J. Wysocki
2023-09-22 9:28 ` Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230921170045.4189251-1-bgeffon@google.com \
--to=bgeffon@google.com \
--cc=len.brown@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=mka@chromium.org \
--cc=pavel@ucw.cz \
--cc=rafael@kernel.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox