linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] crypto: caam - Fix error handling in caam_rng_init()
@ 2015-08-12 14:48 Fabio Estevam
  2015-08-12 17:14 ` Horia Geantă
  2015-08-13  7:17 ` Herbert Xu
  0 siblings, 2 replies; 3+ messages in thread
From: Fabio Estevam @ 2015-08-12 14:48 UTC (permalink / raw)
  To: herbert
  Cc: vicki.milhoan, steve.cornelius, horia.geanta, linux-crypto,
	Fabio Estevam

From: Fabio Estevam <fabio.estevam@freescale.com>

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>
---
 drivers/crypto/caam/caamrng.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/crypto/caam/caamrng.c b/drivers/crypto/caam/caamrng.c
index 345024c..fb0cc54 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);
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] crypto: caam - Fix error handling in caam_rng_init()
  2015-08-12 14:48 [PATCH] crypto: caam - Fix error handling in caam_rng_init() Fabio Estevam
@ 2015-08-12 17:14 ` Horia Geantă
  2015-08-13  7:17 ` Herbert Xu
  1 sibling, 0 replies; 3+ messages in thread
From: Horia Geantă @ 2015-08-12 17:14 UTC (permalink / raw)
  To: Fabio Estevam, herbert
  Cc: vicki.milhoan, steve.cornelius, linux-crypto, Fabio Estevam

On 8/12/2015 5:48 PM, Fabio Estevam wrote:
> From: Fabio Estevam <fabio.estevam@freescale.com>
> 
> 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>

Thanks,
Horia

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] crypto: caam - Fix error handling in caam_rng_init()
  2015-08-12 14:48 [PATCH] crypto: caam - Fix error handling in caam_rng_init() Fabio Estevam
  2015-08-12 17:14 ` Horia Geantă
@ 2015-08-13  7:17 ` Herbert Xu
  1 sibling, 0 replies; 3+ messages in thread
From: Herbert Xu @ 2015-08-13  7:17 UTC (permalink / raw)
  To: Fabio Estevam
  Cc: vicki.milhoan, steve.cornelius, horia.geanta, linux-crypto,
	Fabio Estevam

On Wed, Aug 12, 2015 at 11:48:42AM -0300, Fabio Estevam wrote:
> From: Fabio Estevam <fabio.estevam@freescale.com>
> 
> 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>

Applied.
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-08-13  7:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-12 14:48 [PATCH] crypto: caam - Fix error handling in caam_rng_init() Fabio Estevam
2015-08-12 17:14 ` Horia Geantă
2015-08-13  7:17 ` Herbert Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).