diff options
author | Tom Lendacky <thomas.lendacky@amd.com> | 2018-07-26 10:37:59 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2018-08-03 06:06:05 -0400 |
commit | afb31cd2d1a1bc3ca055fb2519ec4e9ab969ffe0 (patch) | |
tree | e5d09fd0285a72defbdfb44c01c84e38fe0dbfdc /drivers/crypto/ccp/psp-dev.c | |
parent | 4e34e51f48ab7f77a4022aa810a786daa3eb3e22 (diff) |
crypto: ccp - Check for NULL PSP pointer at module unload
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: <stable@vger.kernel.org> # 4.16.x-
Fixes: 2a6170dfe755 ("crypto: ccp: Add Platform Security Processor (PSP) device support")
Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
Acked-by: Gary R Hook <gary.hook@amd.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/crypto/ccp/psp-dev.c')
-rw-r--r-- | drivers/crypto/ccp/psp-dev.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/crypto/ccp/psp-dev.c b/drivers/crypto/ccp/psp-dev.c index 9b596387a09f..218739b961fe 100644 --- a/drivers/crypto/ccp/psp-dev.c +++ b/drivers/crypto/ccp/psp-dev.c | |||
@@ -858,6 +858,9 @@ void psp_dev_destroy(struct sp_device *sp) | |||
858 | { | 858 | { |
859 | struct psp_device *psp = sp->psp_data; | 859 | struct psp_device *psp = sp->psp_data; |
860 | 860 | ||
861 | if (!psp) | ||
862 | return; | ||
863 | |||
861 | if (psp->sev_misc) | 864 | if (psp->sev_misc) |
862 | kref_put(&misc_dev->refcount, sev_exit); | 865 | kref_put(&misc_dev->refcount, sev_exit); |
863 | 866 | ||