2019-08-19 22:26:16

by Gary R Hook

[permalink] [raw]
Subject: [PATCH] crypto: ccp - Ignore unconfigured CCP device on suspend/resume

From: Gary R Hook <[email protected]>

If a CCP is unconfigured (e.g. there are no available queues) then
there will be no data structures allocated for the device. Thus, we
must check for validity of a pointer before trying to access structure
members.

Fixes: 720419f01832f ("crypto: ccp - Introduce the AMD Secure Processor device")

Signed-off-by: Gary R Hook <[email protected]>
---
drivers/crypto/ccp/ccp-dev.c | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/drivers/crypto/ccp/ccp-dev.c b/drivers/crypto/ccp/ccp-dev.c
index e58d69d4dd43..73acf0fdb793 100644
--- a/drivers/crypto/ccp/ccp-dev.c
+++ b/drivers/crypto/ccp/ccp-dev.c
@@ -555,6 +555,10 @@ int ccp_dev_suspend(struct sp_device *sp, pm_message_t state)
unsigned long flags;
unsigned int i;

+ /* If there's no device there's nothing to do */
+ if (!ccp)
+ return 0;
+
spin_lock_irqsave(&ccp->cmd_lock, flags);

ccp->suspending = 1;
@@ -579,6 +583,10 @@ int ccp_dev_resume(struct sp_device *sp)
unsigned long flags;
unsigned int i;

+ /* If there's no device there's nothing to do */
+ if (!ccp)
+ return 0;
+
spin_lock_irqsave(&ccp->cmd_lock, flags);

ccp->suspending = 0;
--
2.17.1


2019-08-22 07:03:02

by Herbert Xu

[permalink] [raw]
Subject: Re: [PATCH] crypto: ccp - Ignore unconfigured CCP device on suspend/resume

On Mon, Aug 19, 2019 at 10:23:27PM +0000, Hook, Gary wrote:
> From: Gary R Hook <[email protected]>
>
> If a CCP is unconfigured (e.g. there are no available queues) then
> there will be no data structures allocated for the device. Thus, we
> must check for validity of a pointer before trying to access structure
> members.
>
> Fixes: 720419f01832f ("crypto: ccp - Introduce the AMD Secure Processor device")
>
> Signed-off-by: Gary R Hook <[email protected]>
> ---
> drivers/crypto/ccp/ccp-dev.c | 8 ++++++++
> 1 file changed, 8 insertions(+)

Patch applied. Thanks.
--
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt