summaryrefslogtreecommitdiff
path: root/drivers/crypto/caam
diff options
context:
space:
mode:
authorNitesh Lal <NiteshNarayanLal@freescale.com>2014-04-30 11:43:40 (GMT)
committerJose Rivera <German.Rivera@freescale.com>2014-05-01 15:03:30 (GMT)
commit3975ac785ff22dd1e15a29eb28885002a1bd00f2 (patch)
treec5b7146f0a082b6e4a69c98b471b75c26ed7524f /drivers/crypto/caam
parentba7b6331bc2d92a4b29a14f9e8585f25ed792b5f (diff)
downloadlinux-fsl-qoriq-3975ac785ff22dd1e15a29eb28885002a1bd00f2.tar.xz
crypto: caam - Fix crash in caampkc module_init
Added NULL check for private structure in caampkc module. It is NULL when the caam driver fails to properly initialize (e.g. RNG4 init failed), then the module should gracefully do a failed initialization. Signed-off-by: Nitesh Lal <NiteshNarayanLal@freescale.com> Change-Id: If5b3e6ead28c4f45e51b0b7d887fdc57d8a8d194 Reviewed-on: http://git.am.freescale.net:8181/11714 Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com> Reviewed-by: Ruchika Gupta <ruchika.gupta@freescale.com> Reviewed-by: Yashpal Dutta <yashpal.dutta@freescale.com> Reviewed-by: Jose Rivera <German.Rivera@freescale.com>
Diffstat (limited to 'drivers/crypto/caam')
-rw-r--r--drivers/crypto/caam/caampkc.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/drivers/crypto/caam/caampkc.c b/drivers/crypto/caam/caampkc.c
index 8023e55..173fc41 100644
--- a/drivers/crypto/caam/caampkc.c
+++ b/drivers/crypto/caam/caampkc.c
@@ -1420,6 +1420,13 @@ static int __init caam_pkc_init(void)
priv = dev_get_drvdata(ctrldev);
of_node_put(dev_node);
+ /*
+ * If priv is NULL, it's probably because the caam driver wasn't
+ * properly initialized (e.g. RNG4 init failed). Thus, bail out here.
+ */
+ if (!priv)
+ return -ENODEV;
+
INIT_LIST_HEAD(&priv->pkc_list);
/* register crypto algorithms the device supports */