crypto: caam - Fix error handling in caam_rng_init()
PATCH 1/1 crypto: caam - Fix error handling in caam_rng_init()
From: Fabio Estevam <[email protected]>
In the error paths we should free the resources that were previously acquired, so fix it accordingly.
Signed-off-by Fabio Estevam <[email protected]>
--- drivers/crypto/caam/caamrng.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
drivers/crypto/caam/caamrng.c +11 -3
@@ -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);
Signature · 1 line
1.9.1
Quoted 6 lines · Fabio Estevam
From: Fabio Estevam <[email protected]>
In the error paths we should free the resources that were previously acquired, so fix it accordingly.
Signed-off-by Fabio Estevam <[email protected]>
Reviewed-by Horia Geantă <[email protected]>
Thanks,
Horia
Quoted 6 lines · Fabio Estevam
From: Fabio Estevam <[email protected]>
In the error paths we should free the resources that were previously acquired, so fix it accordingly.
Signed-off-by Fabio Estevam <[email protected]>
Applied.
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt