From: Tycho Andersen (AMD) Date: Wed, 29 Apr 2026 15:56:36 +0000 (-0600) Subject: crypto/ccp: Skip SNP_INIT if preparation fails X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e9d29f4a9183b5bd355aaf996bd16ecb69e52eb1;p=thirdparty%2Flinux.git 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) Signed-off-by: Borislav Petkov (AMD) Reviewed-by: Nikunj A Dadhania Link: https://lore.kernel.org/20260429155636.540040-1-tycho@kernel.org --- diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c index d1e9e0ac63b60..78f98aee7a66c 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