diff options
author | Himangi Saraogi <himangi774@gmail.com> | 2014-05-27 14:25:48 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2014-06-20 09:26:06 -0400 |
commit | 4776d381276ddbdec01381c4ae18150263d41ced (patch) | |
tree | eca9add71440ca87c63cc5aae510cf9c41157bc4 /drivers/crypto/caam | |
parent | 42614b0582542a2ab26d86956d92b4f54c69d735 (diff) |
crypto: caam - Introduce the use of the managed version of kzalloc
This patch moves data allocated using kzalloc to managed data allocated
using devm_kzalloc and cleans now unnecessary kfrees in probe and remove
functions. Also, linux/device.h is added to make sure the devm_*()
routine declarations are unambiguously available. Earlier, in the probe
function ctrlpriv was leaked on the failure of ctrl = of_iomap(nprop, 0);
as well as on the failure of ctrlpriv->jrpdev = kzalloc(...); . These
two bugs have been fixed by the patch.
The following Coccinelle semantic patch was used for making the change:
identifier p, probefn, removefn;
@@
struct platform_driver p = {
.probe = probefn,
.remove = removefn,
};
@prb@
identifier platform.probefn, pdev;
expression e, e1, e2;
@@
probefn(struct platform_device *pdev, ...) {
<+...
- e = kzalloc(e1, e2)
+ e = devm_kzalloc(&pdev->dev, e1, e2)
...
?-kfree(e);
...+>
}
@rem depends on prb@
identifier platform.removefn;
expression e;
@@
removefn(...) {
<...
- kfree(e);
...>
}
Signed-off-by: Himangi Saraogi <himangi774@gmail.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
Reviewed-by: Marek Vasut <marex@denx.de>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/crypto/caam')
-rw-r--r-- | drivers/crypto/caam/ctrl.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/drivers/crypto/caam/ctrl.c b/drivers/crypto/caam/ctrl.c index 1c38f86bf63a..34ffc35e3a09 100644 --- a/drivers/crypto/caam/ctrl.c +++ b/drivers/crypto/caam/ctrl.c | |||
@@ -5,6 +5,7 @@ | |||
5 | * Copyright 2008-2012 Freescale Semiconductor, Inc. | 5 | * Copyright 2008-2012 Freescale Semiconductor, Inc. |
6 | */ | 6 | */ |
7 | 7 | ||
8 | #include <linux/device.h> | ||
8 | #include <linux/of_address.h> | 9 | #include <linux/of_address.h> |
9 | #include <linux/of_irq.h> | 10 | #include <linux/of_irq.h> |
10 | 11 | ||
@@ -295,9 +296,6 @@ static int caam_remove(struct platform_device *pdev) | |||
295 | /* Unmap controller region */ | 296 | /* Unmap controller region */ |
296 | iounmap(&topregs->ctrl); | 297 | iounmap(&topregs->ctrl); |
297 | 298 | ||
298 | kfree(ctrlpriv->jrpdev); | ||
299 | kfree(ctrlpriv); | ||
300 | |||
301 | return ret; | 299 | return ret; |
302 | } | 300 | } |
303 | 301 | ||
@@ -382,7 +380,8 @@ static int caam_probe(struct platform_device *pdev) | |||
382 | #endif | 380 | #endif |
383 | u64 cha_vid; | 381 | u64 cha_vid; |
384 | 382 | ||
385 | ctrlpriv = kzalloc(sizeof(struct caam_drv_private), GFP_KERNEL); | 383 | ctrlpriv = devm_kzalloc(&pdev->dev, sizeof(struct caam_drv_private), |
384 | GFP_KERNEL); | ||
386 | if (!ctrlpriv) | 385 | if (!ctrlpriv) |
387 | return -ENOMEM; | 386 | return -ENOMEM; |
388 | 387 | ||
@@ -432,8 +431,9 @@ static int caam_probe(struct platform_device *pdev) | |||
432 | of_device_is_compatible(np, "fsl,sec4.0-job-ring")) | 431 | of_device_is_compatible(np, "fsl,sec4.0-job-ring")) |
433 | rspec++; | 432 | rspec++; |
434 | 433 | ||
435 | ctrlpriv->jrpdev = kzalloc(sizeof(struct platform_device *) * rspec, | 434 | ctrlpriv->jrpdev = devm_kzalloc(&pdev->dev, |
436 | GFP_KERNEL); | 435 | sizeof(struct platform_device *) * rspec, |
436 | GFP_KERNEL); | ||
437 | if (ctrlpriv->jrpdev == NULL) { | 437 | if (ctrlpriv->jrpdev == NULL) { |
438 | iounmap(&topregs->ctrl); | 438 | iounmap(&topregs->ctrl); |
439 | return -ENOMEM; | 439 | return -ENOMEM; |