From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 69E652C1BA; Fri, 24 Nov 2023 18:02:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="qhxS66qn" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E359AC433C7; Fri, 24 Nov 2023 18:02:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1700848923; bh=mmUSu7YYW8ut1DmeeYx+ObNe/JcWwznBCc+UMHOPngI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qhxS66qnZPtHncFSyiagrNRGM4Uupz722A8/yFGbb2gUtTe8O7/rB3D017EZHZqbq dR8QRilW0Q1qOg82Hxv8ZHFta0j8P+LPmV9jipKBbwIHPIjs3e2kQ7UeSNRdn0y0hS NURckOMdhj3Fz7j/G4WUqdR8636CdMSEU0I45pqg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Brian Geffon , "Rafael J. Wysocki" Subject: [PATCH 4.14 36/57] PM: hibernate: Use __get_safe_page() rather than touching the list Date: Fri, 24 Nov 2023 17:51:00 +0000 Message-ID: <20231124171931.631807106@linuxfoundation.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231124171930.281665051@linuxfoundation.org> References: <20231124171930.281665051@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Brian Geffon 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 Fixes: 8357376d3df2 ("[PATCH] swsusp: Improve handling of highmem") Cc: All applicable Signed-off-by: Rafael J. Wysocki Signed-off-by: Greg Kroah-Hartman --- kernel/power/snapshot.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) --- a/kernel/power/snapshot.c +++ b/kernel/power/snapshot.c @@ -2377,8 +2377,9 @@ static void *get_highmem_page_buffer(str 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; @@ -2558,8 +2559,9 @@ static void *get_buffer(struct memory_bi 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;