Add missing NULL checks in CAAM sm

Missing NULL checks in CAAM sm_store and sm_test cause kernel
    crashes if caam init fails.

Signed-off-by: Radu Solea <radu.solea@nxp.com>
Signed-off-by: Vipul Kumar <vipul_kumar@mentor.com>
This commit is contained in:
Radu Solea 2017-03-08 16:34:15 +02:00 committed by Leonard Crestez
parent 0e6ed5a819
commit b1254b6b5f
2 changed files with 15 additions and 2 deletions

View File

@ -1,4 +1,3 @@
/*
* CAAM Secure Memory Storage Interface
* Copyright (C) 2008-2015 Freescale Semiconductor, Inc.
@ -1004,6 +1003,13 @@ int caam_sm_startup(struct platform_device *pdev)
ctrldev = &pdev->dev;
ctrlpriv = dev_get_drvdata(ctrldev);
/*
* If ctrlpriv is NULL, it's probably because the caam driver wasn't
* properly initialized (e.g. RNG4 init failed). Thus, bail out here.
*/
if (!ctrlpriv)
return -ENODEV;
/*
* Set up the private block for secure memory
* Only one instance is possible

View File

@ -1,4 +1,3 @@
/*
* Secure Memory / Keystore Exemplification Module
* Copyright (C) 2012-2015 Freescale Semiconductor, Inc. All Rights Reserved
@ -106,6 +105,14 @@ int caam_sm_example_init(struct platform_device *pdev)
*/
ctrldev = &pdev->dev;
ctrlpriv = dev_get_drvdata(ctrldev);
/*
* If ctrlpriv is NULL, it's probably because the caam driver wasn't
* properly initialized (e.g. RNG4 init failed). Thus, bail out here.
*/
if (!ctrlpriv)
return -ENODEV;
ksdev = ctrlpriv->smdev;
kspriv = dev_get_drvdata(ksdev);
if (kspriv == NULL)