]> git.hungrycats.org Git - linux/commit
crypto: ccp - Check for NULL PSP pointer at module unload
authorTom Lendacky <thomas.lendacky@amd.com>
Thu, 26 Jul 2018 14:37:59 +0000 (09:37 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 17 Aug 2018 19:02:43 +0000 (21:02 +0200)
commit80a5eb6b3745b6bdfdf19f4687dba46aeffdb639
treec367b11d0ba124fb05f1f51dc7049840696715c0
parenta2a9b8b34cc83b7a21002ba021b5057ae6e6a8ee
crypto: ccp - Check for NULL PSP pointer at module unload

commit afb31cd2d1a1bc3ca055fb2519ec4e9ab969ffe0 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: <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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/crypto/ccp/psp-dev.c