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>
-
/*
* CAAM Secure Memory Storage Interface
* Copyright (C) 2008-2015 Freescale Semiconductor, Inc.
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
-
/*
* Secure Memory / Keystore Exemplification Module
* Copyright (C) 2012-2015 Freescale Semiconductor, Inc. All Rights Reserved
*/
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)