Skip to contentSkip to conversation

drivers/clocksource/cyclone.c: Move up iounmap

PATCH New Julia Lawall 1 participant 1 message Aug 27, 2010

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

PATCH 1/2 drivers/clocksource/cyclone.c: Move up iounmap

By moving the iounmap up above the test, it takes place whether the test succeeds or fails.

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

// <smpl>
@r exists@
local idexpression x;
expression E,E1;
identifier l;
statement S;
@@

*x = ioremap_nocache(...);
...
if (x = NULL) S
... when != iounmap(x)

    when != if (...) { ... iounmap(x); ... }
    when != E = x
if (...) {
  ... when != iounmap(x)
      when != if (...) { ... iounmap(x); ... }

(
return <+...x...+>;
|
* return ...;
)
}
... when != x = E1
iounmap(x);
// </smpl>

---
 drivers/clocksource/cyclone.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clocksource/cyclone.c +1 -1
index 64e528e..4c62e20 100644
@@ -57,11 +57,11 @@ static int __init init_cyclone_clocksource(void)
 	}
 	/* even on 64bit systems, this is only 32bits: */
 	base = readl(reg);
+	iounmap(reg);
 	if (!base) {
 		printk(KERN_ERR "Summit chipset: Could not find valid CBAR value.\n");
 		return -ENODEV;
 	}
-	iounmap(reg);
 
 	/* setup PMCC: */
 	offset = base + CYCLONE_PMCC_OFFSET;