Skip to content

Commit

Permalink
arch/powerpc/platforms/83xx/mpc837x_mds.c: Add missing iounmap
Browse files Browse the repository at this point in the history
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 <julia@diku.dk>
Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
  • Loading branch information
Julia Lawall authored and Kumar Gala committed Aug 31, 2010
1 parent ff33f18 commit fa9fc82
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions arch/powerpc/platforms/83xx/mpc837x_mds.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -65,8 +67,9 @@ static int mpc837xmds_usb_cfg(void)
}

of_node_put(np);
out:
iounmap(bcsr_regs);
return 0;
return ret;
}

/* ************************************************************************
Expand Down

0 comments on commit fa9fc82

Please sign in to comment.