public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: SVM: snp_alloc_firmware_pages: memory leak
@ 2025-02-14  3:59 Alexey Kardashevskiy
  2025-02-14 14:53 ` Tom Lendacky
  0 siblings, 1 reply; 4+ messages in thread
From: Alexey Kardashevskiy @ 2025-02-14  3:59 UTC (permalink / raw)
  To: linux-crypto
  Cc: linux-kernel, Ashish Kalra, Tom Lendacky, Alexey Kardashevskiy

Failure to rmpupdate leads to page(s) leak, fix that.

Signed-off-by: Alexey Kardashevskiy <aik@amd.com>
---
 drivers/crypto/ccp/sev-dev.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c
index 2e87ca0e292a..0b5f8ab657c5 100644
--- a/drivers/crypto/ccp/sev-dev.c
+++ b/drivers/crypto/ccp/sev-dev.c
@@ -443,8 +443,10 @@ static struct page *__snp_alloc_firmware_pages(gfp_t gfp_mask, int order)
 		return page;
 
 	paddr = __pa((unsigned long)page_address(page));
-	if (rmp_mark_pages_firmware(paddr, npages, false))
+	if (rmp_mark_pages_firmware(paddr, npages, false)) {
+		__free_pages(page, order);
 		return NULL;
+	}
 
 	return page;
 }
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-02-18 14:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-14  3:59 [PATCH] KVM: SVM: snp_alloc_firmware_pages: memory leak Alexey Kardashevskiy
2025-02-14 14:53 ` Tom Lendacky
2025-02-18  1:24   ` Alexey Kardashevskiy
2025-02-18 14:42     ` Tom Lendacky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox