* [PATCH 3/6] drivers/char/hw_random/octeon-rng.c: drop frees of devm allocated data
@ 2012-08-04 16:50 Julia Lawall
2012-08-20 8:31 ` Herbert Xu
0 siblings, 1 reply; 2+ messages in thread
From: Julia Lawall @ 2012-08-04 16:50 UTC (permalink / raw)
To: Matt Mackall; +Cc: kernel-janitors, Herbert Xu, linux-kernel
From: Julia Lawall <Julia.Lawall@lip6.fr>
devm_kfree and devm_iounmap should not have to be explicitly used.
The semantic patch that fixes this problem is as follows:
(http://coccinelle.lip6.fr/)
// <smpl>
@@
expression x,d;
@@
x = devm_kzalloc(...)
...
?-devm_kfree(d,x);
// </smpl>
Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
---
drivers/char/hw_random/octeon-rng.c | 17 +++++------------
1 file changed, 5 insertions(+), 12 deletions(-)
diff --git a/drivers/char/hw_random/octeon-rng.c b/drivers/char/hw_random/octeon-rng.c
index 0943edc..5c34c09 100644
--- a/drivers/char/hw_random/octeon-rng.c
+++ b/drivers/char/hw_random/octeon-rng.c
@@ -75,42 +75,35 @@ static int __devinit octeon_rng_probe(struct platform_device *pdev)
res_ports = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res_ports)
- goto err_ports;
+ return -ENOENT;
res_result = platform_get_resource(pdev, IORESOURCE_MEM, 1);
if (!res_result)
- goto err_ports;
+ return -ENOENT;
rng->control_status = devm_ioremap_nocache(&pdev->dev,
res_ports->start,
sizeof(u64));
if (!rng->control_status)
- goto err_ports;
+ return -ENOENT;
rng->result = devm_ioremap_nocache(&pdev->dev,
res_result->start,
sizeof(u64));
if (!rng->result)
- goto err_r;
+ return -ENOENT;
rng->ops = ops;
dev_set_drvdata(&pdev->dev, &rng->ops);
ret = hwrng_register(&rng->ops);
if (ret)
- goto err;
+ return -ENOENT;
dev_info(&pdev->dev, "Octeon Random Number Generator\n");
return 0;
-err:
- devm_iounmap(&pdev->dev, rng->control_status);
-err_r:
- devm_iounmap(&pdev->dev, rng->result);
-err_ports:
- devm_kfree(&pdev->dev, rng);
- return -ENOENT;
}
static int __exit octeon_rng_remove(struct platform_device *pdev)
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 3/6] drivers/char/hw_random/octeon-rng.c: drop frees of devm allocated data
2012-08-04 16:50 [PATCH 3/6] drivers/char/hw_random/octeon-rng.c: drop frees of devm allocated data Julia Lawall
@ 2012-08-20 8:31 ` Herbert Xu
0 siblings, 0 replies; 2+ messages in thread
From: Herbert Xu @ 2012-08-20 8:31 UTC (permalink / raw)
To: Julia Lawall; +Cc: Matt Mackall, kernel-janitors, linux-kernel
On Sat, Aug 04, 2012 at 06:50:46PM +0200, Julia Lawall wrote:
> From: Julia Lawall <Julia.Lawall@lip6.fr>
>
> devm_kfree and devm_iounmap should not have to be explicitly used.
>
> The semantic patch that fixes this problem is as follows:
> (http://coccinelle.lip6.fr/)
>
> // <smpl>
> @@
> expression x,d;
> @@
>
> x = devm_kzalloc(...)
> ...
> ?-devm_kfree(d,x);
> // </smpl>
>
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
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] 2+ messages in thread
end of thread, other threads:[~2012-08-20 8:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-04 16:50 [PATCH 3/6] drivers/char/hw_random/octeon-rng.c: drop frees of devm allocated data Julia Lawall
2012-08-20 8:31 ` 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).