Skip to contentSkip to conversation

virt: sevguest: Fix return value check in alloc_shared_pages()

PATCH Applied Yang Yingliang 3 participants 3 messages Apr 11, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 virt: sevguest: Fix return value check in alloc_shared_pages()

If alloc_pages() fails, it returns NULL pointer, replaces IS_ERR() check with NULL pointer check.

Fixes fce96cf04430 ("virt: Add SEV-SNP guest driver")
---
 drivers/virt/coco/sevguest/sevguest.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/virt/coco/sevguest/sevguest.c +1 -1
index 15afb6ce8d19..aaa6134d1d40 100644
@@ -581,7 +581,7 @@ static void *alloc_shared_pages(size_t sz)
 	int ret;
 
 	page = alloc_pages(GFP_KERNEL_ACCOUNT, get_order(sz));
-	if (IS_ERR(page))
+	if (!page)
 		return NULL;
 
 	ret = set_memory_decrypted((unsigned long)page_address(page), npages);
Signature · 1 line
2.25.1
merge bot Applied
#2 lore raw
In reply to Yang Yingliang
The following commit has been merged into the x86/sev branch of tip:

The following commit has been merged into the x86/sev branch of tip:

Commit-ID:     e50abbf788c239d529f9ab81e325f8e8f8432c9d
Gitweb:        https://git.kernel.org/tip/e50abbf788c239d529f9ab81e325f8e8f8432c9d
Author:        Yang Yingliang <[email protected]>
AuthorDate:    Mon, 11 Apr 2022 19:12:13 +08:00
Committer:     Borislav Petkov <[email protected]>
CommitterDate: Mon, 11 Apr 2022 17:58:52 +02:00

virt: sevguest: Fix return value check in alloc_shared_pages()

If alloc_pages() fails, it returns a NULL pointer. Replace the wrong IS_ERR() check with the proper NULL pointer check.

---
 drivers/virt/coco/sevguest/sevguest.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/virt/coco/sevguest/sevguest.c +1 -1
index 15afb6c..aaa6134 100644
@@ -581,7 +581,7 @@ static void *alloc_shared_pages(size_t sz)
 	int ret;
 
 	page = alloc_pages(GFP_KERNEL_ACCOUNT, get_order(sz));
-	if (IS_ERR(page))
+	if (!page)
 		return NULL;
 
 	ret = set_memory_decrypted((unsigned long)page_address(page), npages);