Skip to contentSkip to conversation

arch/arm/mach-omap2/smartreflex.c: add missing error-handling code

PATCH Applied Julia Lawall 2 participants 2 messages Jul 4, 2011 – Jul 5, 2011

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 3/5 arch/arm/mach-omap2/smartreflex.c: add missing error-handling code

From: Julia Lawall <[email protected]>

At this point, the ioremap has taken place, so the error handling code at the label err_iounmap should be used rather than returning directly.

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

// <smpl>
@r@
identifier x;
@@

kfree(x)

@@
identifier r.x;
expression E1!=0,E2,E3,E4;
statement S;
@@

(
if (<+...x...+>) S
|
if (...) { ... when != kfree(x)

               when != if (...) { ... kfree(x); ... }
               when != x = E3

* return E1;
}
... when != x = E2
if (...) { ... when != x = E4
kfree(x); ... return ...; }
)
// </smpl>

---
 arch/arm/mach-omap2/smartreflex.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-omap2/smartreflex.c +1 -1
index fb7dc52..e8280df 100644
@@ -891,7 +891,7 @@ static int __init omap_sr_probe(struct platform_device *pdev)
 		ret = sr_late_init(sr_info);
 		if (ret) {
 			pr_warning("%s: Error in SR late init\n", __func__);
-			return ret;
+			goto err_iounmap;
 		}
 	}
 
Acked-by on v1 3/5
#1 lore raw
Quoted 35 lines · Julia Lawall

From: Julia Lawall <[email protected]>

At this point, the ioremap has taken place, so the error handling code at the label err_iounmap should be used rather than returning directly.

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

// <smpl>
@r@
identifier x;
@@

kfree(x)

@@
identifier r.x;
expression E1!=0,E2,E3,E4;
statement S;
@@

(
if (<+...x...+>) S
|
if (...) { ... when != kfree(x)

               when != if (...) { ... kfree(x); ... }
               when != x = E3

* return E1;
}
... when != x = E2
if (...) { ... when != x = E4
kfree(x); ... return ...; }
)
// </smpl>

Quoted 1 line

Tony, can you add this to devel-fixes?

Kevin