diff options
author | Fabio Estevam <fabio.estevam@freescale.com> | 2015-08-12 11:48:42 -0300 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2015-08-13 15:13:29 +0800 |
commit | ac8ad30777467c5258c52aa4899a8a07a3e56b54 (patch) | |
tree | 10b777c916d2a8f6ecce0fb0d83177e17fff366f /drivers/crypto | |
parent | 8669f34e122bad56e4d3ecde5f4720c40261bf4c (diff) |
crypto: caam - Fix error handling in caam_rng_init()
In the error paths we should free the resources that were
previously acquired, so fix it accordingly.
Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
Reviewed-by: Horia Geant? <horia.geanta@freescale.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/crypto')
-rw-r--r-- | drivers/crypto/caam/caamrng.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/drivers/crypto/caam/caamrng.c b/drivers/crypto/caam/caamrng.c index 345024c22467..fb0cc54fa70c 100644 --- a/drivers/crypto/caam/caamrng.c +++ b/drivers/crypto/caam/caamrng.c @@ -352,14 +352,22 @@ static int __init caam_rng_init(void) return PTR_ERR(dev); } rng_ctx = kmalloc(sizeof(struct caam_rng_ctx), GFP_DMA); - if (!rng_ctx) - return -ENOMEM; + if (!rng_ctx) { + err = -ENOMEM; + goto free_caam_alloc; + } err = caam_init_rng(rng_ctx, dev); if (err) - return err; + goto free_rng_ctx; dev_info(dev, "registering rng-caam\n"); return hwrng_register(&caam_rng); + +free_rng_ctx: + kfree(rng_ctx); +free_caam_alloc: + caam_jr_free(dev); + return err; } module_init(caam_rng_init); |