Re: [PATCH] arch/powerpc/platforms/83xx/mpc837x_mds.c: Add missing iounmap

2010-08-31 Thread Kumar Gala

On Aug 29, 2010, at 2:47 PM, Julia Lawall wrote:

 The function of_iomap returns the result of calling ioremap, so iounmap
 should be called on the result in the error handling code, as done in the
 normal exit of the function.
 
 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 = of_iomap(...);
 ...  when != iounmap(x)
 when != if (...) { ... iounmap(x); ... }
 when != E = x
 when any
 (
 if (x == NULL) S
 |
 if (...) {
  ... when != iounmap(x)
  when != if (...) { ... iounmap(x); ... }
 (
  return +...x...+;
 |
 *  return ...;
 )
 }
 )
 ... when != x = E1
when any
 iounmap(x);
 // /smpl
 
 Signed-off-by: Julia Lawall ju...@diku.dk
 
 ---
 arch/powerpc/platforms/83xx/mpc837x_mds.c |9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

applied to merge

- k
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[PATCH] arch/powerpc/platforms/83xx/mpc837x_mds.c: Add missing iounmap

2010-08-29 Thread Julia Lawall
The function of_iomap returns the result of calling ioremap, so iounmap
should be called on the result in the error handling code, as done in the
normal exit of the function.

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 = of_iomap(...);
...  when != iounmap(x)
 when != if (...) { ... iounmap(x); ... }
 when != E = x
 when any
(
if (x == NULL) S
|
if (...) {
  ... when != iounmap(x)
  when != if (...) { ... iounmap(x); ... }
(
  return +...x...+;
|
*  return ...;
)
}
)
... when != x = E1
when any
iounmap(x);
// /smpl

Signed-off-by: Julia Lawall ju...@diku.dk

---
 arch/powerpc/platforms/83xx/mpc837x_mds.c |9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/platforms/83xx/mpc837x_mds.c 
b/arch/powerpc/platforms/83xx/mpc837x_mds.c
index f9751c8..8306832 100644
--- a/arch/powerpc/platforms/83xx/mpc837x_mds.c
+++ b/arch/powerpc/platforms/83xx/mpc837x_mds.c
@@ -48,8 +48,10 @@ static int mpc837xmds_usb_cfg(void)
return -1;
 
np = of_find_node_by_name(NULL, usb);
-   if (!np)
-   return -ENODEV;
+   if (!np) {
+   ret = -ENODEV;
+   goto out;
+   }
phy_type = of_get_property(np, phy_type, NULL);
if (phy_type  !strcmp(phy_type, ulpi)) {
clrbits8(bcsr_regs + 12, BCSR12_USB_SER_PIN);
@@ -65,8 +67,9 @@ static int mpc837xmds_usb_cfg(void)
}
 
of_node_put(np);
+out:
iounmap(bcsr_regs);
-   return 0;
+   return ret;
 }
 
 /* 

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev