Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Julia Lawall and committed by
Linus Torvalds
80d02d27 678ff896

+14 -14
+14 -14
drivers/w1/masters/omap_hdq.c
··· 593 593 594 594 /* get interface & functional clock objects */ 595 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)) { 599 - dev_dbg(&pdev->dev, "Can't get HDQ clock objects\n"); 600 - if (IS_ERR(hdq_data->hdq_ick)) { 601 - ret = PTR_ERR(hdq_data->hdq_ick); 602 - goto err_clk; 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 - } 602 + hdq_data->hdq_fck = clk_get(&pdev->dev, "fck"); 603 + if (IS_ERR(hdq_data->hdq_fck)) { 604 + dev_dbg(&pdev->dev, "Can't get HDQ fck clock object\n"); 605 + ret = PTR_ERR(hdq_data->hdq_fck); 606 + goto err_fck; 609 607 } 610 608 611 609 hdq_data->hdq_usecount = 0; ··· 663 665 clk_disable(hdq_data->hdq_ick); 664 666 665 667 err_intfclk: 666 - clk_put(hdq_data->hdq_ick); 667 668 clk_put(hdq_data->hdq_fck); 668 669 669 - err_clk: 670 + err_fck: 671 + clk_put(hdq_data->hdq_ick); 672 + 673 + err_ick: 670 674 iounmap(hdq_data->hdq_base); 671 675 672 676 err_ioremap: