Skip to contentSkip to conversation

crypto: ccp - Ignore unconfigured CCP device on suspend/resume

PATCH In review Hook, Gary 2 participants 2 messages Aug 19, 2019 – Aug 22, 2019

Subsystems (2)
lore
Share & tools
lore

Hook, Gary

author
#0 lore raw

PATCH 1/1 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")
---
 drivers/crypto/ccp/ccp-dev.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/crypto/ccp/ccp-dev.c +8 -0
index e58d69d4dd43..73acf0fdb793 100644
@@ -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;
Signature · 1 line
2.17.1
maintainer
#1 lore raw
Quoted 7 lines · Gary

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.

Quoted 6 lines
Fixes 720419f01832f ("crypto: ccp - Introduce the AMD Secure Processor device")
---
 drivers/crypto/ccp/ccp-dev.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Patch applied. Thanks.

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt