[tip: x86/sev] crypto/ccp: Skip SNP_INIT if preparation fails

tip-bot2 for Tycho Andersen (AMD) posted 1 patch 1 month ago
drivers/crypto/ccp/sev-dev.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
[tip: x86/sev] crypto/ccp: Skip SNP_INIT if preparation fails
Posted by tip-bot2 for Tycho Andersen (AMD) 1 month ago
The following commit has been merged into the x86/sev branch of tip:

Commit-ID:     e9d29f4a9183b5bd355aaf996bd16ecb69e52eb1
Gitweb:        https://git.kernel.org/tip/e9d29f4a9183b5bd355aaf996bd16ecb69e52eb1
Author:        Tycho Andersen (AMD) <tycho@kernel.org>
AuthorDate:    Wed, 29 Apr 2026 09:56:36 -06:00
Committer:     Borislav Petkov (AMD) <bp@alien8.de>
CommitterDate: Fri, 08 May 2026 20:29:40 +02:00

crypto/ccp: Skip SNP_INIT if preparation fails

If snp_prepare() fails, SNP_INIT will fail, so skip it and return early.

Note that this is not a change in initialization behavior: if SNP_INIT fails
even before this change, it will still return an error and
__sev_snp_init_locked() will fail initialization of other SEV modes.

Signed-off-by: Tycho Andersen (AMD) <tycho@kernel.org>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Nikunj A Dadhania <nikunj@amd.com>
Link: https://lore.kernel.org/20260429155636.540040-1-tycho@kernel.org
---
 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 d1e9e0a..78f98ae 100644
--- a/drivers/crypto/ccp/sev-dev.c
+++ b/drivers/crypto/ccp/sev-dev.c
@@ -1374,7 +1374,9 @@ static int __sev_snp_init_locked(int *error, unsigned int max_snp_asid)
 		return -EOPNOTSUPP;
 	}
 
-	snp_prepare();
+	rc = snp_prepare();
+	if (rc)
+		return rc;
 
 	/*
 	 * Starting in SNP firmware v1.52, the SNP_INIT_EX command takes a list