diff mbox series

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

Message ID 20190819222315.61244-1-gary.hook@amd.com (mailing list archive)
State Accepted
Delegated to: Herbert Xu
Headers show
Series crypto: ccp - Ignore unconfigured CCP device on suspend/resume | expand

Commit Message

Gary R Hook Aug. 19, 2019, 10:23 p.m. UTC
From: Gary R Hook <gary.hook@amd.com>

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 <gary.hook@amd.com>
---
 drivers/crypto/ccp/ccp-dev.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Herbert Xu Aug. 22, 2019, 5:55 a.m. UTC | #1
On Mon, Aug 19, 2019 at 10:23:27PM +0000, Hook, Gary wrote:
> From: Gary R Hook <gary.hook@amd.com>
> 
> 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 <gary.hook@amd.com>
> ---
>  drivers/crypto/ccp/ccp-dev.c | 8 ++++++++
>  1 file changed, 8 insertions(+)

Patch applied.  Thanks.
diff mbox series

Patch

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;