Commit 93aff32d authored by Tom Lendacky's avatar Tom Lendacky Committed by Greg Kroah-Hartman
Browse files

crypto: ccp - Check for NULL PSP pointer at module unload

commit afb31cd2 upstream.

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: <> # 4.16.x-
Fixes: 2a6170df

 ("crypto: ccp: Add Platform Security Processor (PSP) device support")
Signed-off-by: default avatarTom Lendacky <>
Acked-by: default avatarGary R Hook <>
Signed-off-by: default avatarHerbert Xu <>
Signed-off-by: default avatarGreg Kroah-Hartman <>
parent 9113175f
......@@ -856,6 +856,9 @@ void psp_dev_destroy(struct sp_device *sp)
struct psp_device *psp = sp->psp_data;
if (!psp)
if (psp->sev_misc)
kref_put(&misc_dev->refcount, sev_exit);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment