Skip to content

Commit 1b05ece

Browse files
tlendackyherbertx
authored andcommitted
crypto: ccp - During shutdown, check SEV data pointer before using
On shutdown, each CCP device instance performs shutdown processing. However, __sev_platform_shutdown_locked() uses the controlling psp structure to obtain the pointer to the sev_device structure. However, during driver initialization, it is possible that an error can be received from the firmware that results in the sev_data pointer being cleared from the controlling psp structure. The __sev_platform_shutdown_locked() function does not check for this situation and will segfault. While not common, this scenario should be accounted for. Add a check for a NULL sev_device structure before attempting to use it. Fixes: 5441a07 ("crypto: ccp - shutdown SEV firmware on kexec") Signed-off-by: Tom Lendacky <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent bffa1fc commit 1b05ece

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/crypto/ccp/sev-dev.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ static int __sev_platform_shutdown_locked(int *error)
503503
struct sev_device *sev = psp_master->sev_data;
504504
int ret;
505505

506-
if (sev->state == SEV_STATE_UNINIT)
506+
if (!sev || sev->state == SEV_STATE_UNINIT)
507507
return 0;
508508

509509
ret = __sev_do_cmd_locked(SEV_CMD_SHUTDOWN, NULL, error);

0 commit comments

Comments
 (0)