diff options
author | Julia Lawall <julia@diku.dk> | 2011-02-10 18:01:37 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-02-11 19:12:20 -0500 |
commit | 80d02d273641d515269c016d9e8da5882e4432e4 (patch) | |
tree | 48775b39bc9edfea0377d604f928912e3bc289fd /drivers/w1 | |
parent | 678ff896a37afdbca292c7846ec895463aed35a5 (diff) |
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: Julia Lawall <julia@diku.dk>
Cc: Evgeniy Polyakov <johnpol@2ka.mipt.ru>
Acked-by: Tony Lindgren <tony@atomide.com>
Acked-by: Amit Kucheria <amit.kucheria@canonical.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/w1')
-rw-r--r-- | drivers/w1/masters/omap_hdq.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/drivers/w1/masters/omap_hdq.c b/drivers/w1/masters/omap_hdq.c index 3a7e9ff8a746..38e96ab90945 100644 --- a/drivers/w1/masters/omap_hdq.c +++ b/drivers/w1/masters/omap_hdq.c | |||
@@ -593,19 +593,17 @@ static int __devinit omap_hdq_probe(struct platform_device *pdev) | |||
593 | 593 | ||
594 | /* get interface & functional clock objects */ | 594 | /* get interface & functional clock objects */ |
595 | hdq_data->hdq_ick = clk_get(&pdev->dev, "ick"); | 595 | hdq_data->hdq_ick = clk_get(&pdev->dev, "ick"); |
596 | hdq_data->hdq_fck = clk_get(&pdev->dev, "fck"); | 596 | if (IS_ERR(hdq_data->hdq_ick)) { |
597 | dev_dbg(&pdev->dev, "Can't get HDQ ick clock object\n"); | ||
598 | ret = PTR_ERR(hdq_data->hdq_ick); | ||
599 | goto err_ick; | ||
600 | } | ||
597 | 601 | ||
598 | if (IS_ERR(hdq_data->hdq_ick) || IS_ERR(hdq_data->hdq_fck)) { | 602 | hdq_data->hdq_fck = clk_get(&pdev->dev, "fck"); |
599 | dev_dbg(&pdev->dev, "Can't get HDQ clock objects\n"); | 603 | if (IS_ERR(hdq_data->hdq_fck)) { |
600 | if (IS_ERR(hdq_data->hdq_ick)) { | 604 | dev_dbg(&pdev->dev, "Can't get HDQ fck clock object\n"); |
601 | ret = PTR_ERR(hdq_data->hdq_ick); | 605 | ret = PTR_ERR(hdq_data->hdq_fck); |
602 | goto err_clk; | 606 | goto err_fck; |
603 | } | ||
604 | if (IS_ERR(hdq_data->hdq_fck)) { | ||
605 | ret = PTR_ERR(hdq_data->hdq_fck); | ||
606 | clk_put(hdq_data->hdq_ick); | ||
607 | goto err_clk; | ||
608 | } | ||
609 | } | 607 | } |
610 | 608 | ||
611 | hdq_data->hdq_usecount = 0; | 609 | hdq_data->hdq_usecount = 0; |
@@ -665,10 +663,12 @@ err_fnclk: | |||
665 | clk_disable(hdq_data->hdq_ick); | 663 | clk_disable(hdq_data->hdq_ick); |
666 | 664 | ||
667 | err_intfclk: | 665 | err_intfclk: |
668 | clk_put(hdq_data->hdq_ick); | ||
669 | clk_put(hdq_data->hdq_fck); | 666 | clk_put(hdq_data->hdq_fck); |
670 | 667 | ||
671 | err_clk: | 668 | err_fck: |
669 | clk_put(hdq_data->hdq_ick); | ||
670 | |||
671 | err_ick: | ||
672 | iounmap(hdq_data->hdq_base); | 672 | iounmap(hdq_data->hdq_base); |
673 | 673 | ||
674 | err_ioremap: | 674 | err_ioremap: |