[PATCH 3.14 30/66] crypto: caam - fix memleak in caam_jr module

From: Greg Kroah-Hartman
Date: Tue Jul 15 2014 - 19:59:55 EST


3.14-stable review patch. If anyone has any objections, please let me know.

------------------

From: Cristian Stoica <cristian.stoica@xxxxxxxxxxxxx>

commit 0378c9a855bfa395f595fbfb049707093e270f69 upstream.

This patch fixes a memory leak that appears when caam_jr module is unloaded.

Signed-off-by: Cristian Stoica <cristian.stoica@xxxxxxxxxxxxx>
Signed-off-by: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>

---
drivers/crypto/caam/jr.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)

--- a/drivers/crypto/caam/jr.c
+++ b/drivers/crypto/caam/jr.c
@@ -453,8 +453,8 @@ static int caam_jr_probe(struct platform
int error;

jrdev = &pdev->dev;
- jrpriv = kmalloc(sizeof(struct caam_drv_private_jr),
- GFP_KERNEL);
+ jrpriv = devm_kmalloc(jrdev, sizeof(struct caam_drv_private_jr),
+ GFP_KERNEL);
if (!jrpriv)
return -ENOMEM;

@@ -487,10 +487,8 @@ static int caam_jr_probe(struct platform

/* Now do the platform independent part */
error = caam_jr_init(jrdev); /* now turn on hardware */
- if (error) {
- kfree(jrpriv);
+ if (error)
return error;
- }

jrpriv->dev = jrdev;
spin_lock(&driver_data.jr_alloc_lock);


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/