Skip to content

Commit

Permalink
crypto: ccp - Check for NULL PSP pointer at module unload
Browse files Browse the repository at this point in the history
Should the PSP initialization fail, the PSP data structure will be
freed and the value contained in the sp_device struct set to NULL.
At module unload, psp_dev_destroy() does not check if the pointer
value is NULL and will end up dereferencing a NULL pointer.

Add a pointer check of the psp_data field in the sp_device struct
in psp_dev_destroy() and return immediately if it is NULL.

Cc: <[email protected]> # 4.16.x-
Fixes: 2a6170d ("crypto: ccp: Add Platform Security Processor (PSP) device support")
Signed-off-by: Tom Lendacky <[email protected]>
Acked-by: Gary R Hook <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
  • Loading branch information
tlendacky authored and herbertx committed Aug 3, 2018
1 parent 4e34e51 commit afb31cd
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/crypto/ccp/psp-dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,9 @@ void psp_dev_destroy(struct sp_device *sp)
{
struct psp_device *psp = sp->psp_data;

if (!psp)
return;

if (psp->sev_misc)
kref_put(&misc_dev->refcount, sev_exit);

Expand Down

0 comments on commit afb31cd

Please sign in to comment.