]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
crypto: caam - fix hash, alg and rng registration if CAAM driver not initialized
authorAlex Porosanu <alexandru.porosanu@freescale.com>
Mon, 9 Sep 2013 15:56:29 +0000 (18:56 +0300)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 13 Sep 2013 11:43:54 +0000 (21:43 +1000)
If the CAAM driver initialization failed (due to various reasons, e.g. RNG4
initialization failed), then the registration of hash/algorithms/rng shouldn't
take place. This patch adds the necessary code to prevent this registration.

Signed-off-by: Alex Porosanu <alexandru.porosanu@freescale.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/caam/caamalg.c
drivers/crypto/caam/caamhash.c
drivers/crypto/caam/caamrng.c

index 7c63b72ecd750f381fef66e8baccc7955351b1b3..86a0d415b9a777d8bdf636a89cbfe0e37e27794f 100644 (file)
@@ -2209,6 +2209,13 @@ static int __init caam_algapi_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->alg_list);
 
        atomic_set(&priv->tfm_count, -1);
index e732bd962e98cc715db6463c7587dbb2511707e3..ca6218eee460f6b71e99bda6475fdde3e8af9e19 100644 (file)
@@ -1833,6 +1833,13 @@ static int __init caam_algapi_hash_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->hash_list);
 
        atomic_set(&priv->tfm_count, -1);
index d1939a9539c06a4204a26b65d3d743d46c2346d3..588ad2288f82a0b328a6addc27b12d2984147a93 100644 (file)
@@ -298,6 +298,13 @@ static int __init caam_rng_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;
+
        caam_init_rng(&rng_ctx, priv->jrdev[0]);
 
        dev_info(priv->jrdev[0], "registering rng-caam\n");