Commit 80d02d27 authored by Julia Lawall's avatar Julia Lawall Committed by Linus Torvalds

drivers/w1/masters/omap_hdq.c: add missing clk_put

This code makes two calls to clk_get, then test both return values and
fails if either failed.

The problem is that in the first inner if, where the first call to
clk_get has failed, it don't know if the second call has failed as well.
So it don't know whether clk_get should be called on the result of the
second call.  Of course, it would be possible to test that value again.
A simpler solution is just to test the result of calling clk_get
directly after each call.

The semantic match that finds this problem is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@r@
position p1,p2;
expression e;
statement S;
@@

e = clk_get@p1(...)
...
if@p2 (IS_ERR(e)) S

@@
expression e;
statement S;
identifier l;
position r.p1, p2 != r.p2;
@@

*e = clk_get@p1(...)
... when != clk_put(e)
*if@p2 (...)
{
  ... when != clk_put(e)
* return ...;
}// </smpl>
Signed-off-by: default avatarJulia Lawall <julia@diku.dk>
Cc: Evgeniy Polyakov <johnpol@2ka.mipt.ru>
Acked-by: default avatarTony Lindgren <tony@atomide.com>
Acked-by: default avatarAmit Kucheria <amit.kucheria@canonical.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 678ff896
...@@ -593,19 +593,17 @@ static int __devinit omap_hdq_probe(struct platform_device *pdev) ...@@ -593,19 +593,17 @@ static int __devinit omap_hdq_probe(struct platform_device *pdev)
/* get interface & functional clock objects */ /* get interface & functional clock objects */
hdq_data->hdq_ick = clk_get(&pdev->dev, "ick"); hdq_data->hdq_ick = clk_get(&pdev->dev, "ick");
hdq_data->hdq_fck = clk_get(&pdev->dev, "fck");
if (IS_ERR(hdq_data->hdq_ick) || IS_ERR(hdq_data->hdq_fck)) {
dev_dbg(&pdev->dev, "Can't get HDQ clock objects\n");
if (IS_ERR(hdq_data->hdq_ick)) { if (IS_ERR(hdq_data->hdq_ick)) {
dev_dbg(&pdev->dev, "Can't get HDQ ick clock object\n");
ret = PTR_ERR(hdq_data->hdq_ick); ret = PTR_ERR(hdq_data->hdq_ick);
goto err_clk; goto err_ick;
} }
hdq_data->hdq_fck = clk_get(&pdev->dev, "fck");
if (IS_ERR(hdq_data->hdq_fck)) { if (IS_ERR(hdq_data->hdq_fck)) {
dev_dbg(&pdev->dev, "Can't get HDQ fck clock object\n");
ret = PTR_ERR(hdq_data->hdq_fck); ret = PTR_ERR(hdq_data->hdq_fck);
clk_put(hdq_data->hdq_ick); goto err_fck;
goto err_clk;
}
} }
hdq_data->hdq_usecount = 0; hdq_data->hdq_usecount = 0;
...@@ -665,10 +663,12 @@ static int __devinit omap_hdq_probe(struct platform_device *pdev) ...@@ -665,10 +663,12 @@ static int __devinit omap_hdq_probe(struct platform_device *pdev)
clk_disable(hdq_data->hdq_ick); clk_disable(hdq_data->hdq_ick);
err_intfclk: err_intfclk:
clk_put(hdq_data->hdq_ick);
clk_put(hdq_data->hdq_fck); clk_put(hdq_data->hdq_fck);
err_clk: err_fck:
clk_put(hdq_data->hdq_ick);
err_ick:
iounmap(hdq_data->hdq_base); iounmap(hdq_data->hdq_base);
err_ioremap: err_ioremap:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment