linux_old1/drivers/net/can
Julia Lawall aed5029ead drivers/net/can/mscan/mpc5xxx_can.c: Add of_node_put to avoid memory leak
Add a call to of_node_put in the error handling code following a call to
of_find_matching_node.

This patch also moves the existing call to of_node_put after the call to
iounmap in the error handling code, to make it possible to jump to
of_node_put without doing iounmap.  These appear to be disjoint operations,
so the ordering doesn't matter.

This patch furthermore changes the -ENODEV result in the error handling
code for of_find_matching_node to a return of 0, as found in the error
handling code for of_iomap, because the return type of the function is
unsigned.

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

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

*x =
(of_find_node_by_path
|of_find_node_by_name
|of_find_node_by_phandle
|of_get_parent
|of_get_next_parent
|of_get_next_child
|of_find_compatible_node
|of_match_node
|of_find_node_by_type
|of_find_node_with_property
|of_find_matching_node
|of_parse_phandle
)(...);
...
if (x == NULL) S
<... when != x = E
*if (...) {
  ... when != of_node_put(x)
      when != if (...) { ... of_node_put(x); ... }
(
  return <+...x...+>;
|
*  return ...;
)
}
...>
(
E2 = x;
|
of_node_put(x);
)
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Reviewed-by: Wolfram Sang <w.sang@pengutronix.de>
Acked-by: Wolfgang Grandegger <wg@grandegger.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2010-09-01 10:57:54 -07:00
..
mscan drivers/net/can/mscan/mpc5xxx_can.c: Add of_node_put to avoid memory leak 2010-09-01 10:57:54 -07:00
sja1000 of/device: Replace struct of_device with struct platform_device 2010-08-06 09:25:50 -06:00
usb can: Add driver for esd CAN-USB/2 device 2010-08-03 16:37:58 -07:00
Kconfig CAN: Add Flexcan CAN controller driver 2010-07-22 18:06:25 +02:00
Makefile CAN: Add Flexcan CAN controller driver 2010-07-22 18:06:25 +02:00
at91_can.c net: trans_start cleanups 2010-05-10 05:01:31 -07:00
bfin_can.c net: trans_start cleanups 2010-05-10 05:01:31 -07:00
dev.c include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h 2010-03-30 22:02:32 +09:00
flexcan.c CAN: Add Flexcan CAN controller driver 2010-07-22 18:06:25 +02:00
janz-ican3.c can: Add support for Janz VMOD-ICAN3 Intelligent CAN module 2010-05-28 01:37:33 +02:00
mcp251x.c net: trans_start cleanups 2010-05-10 05:01:31 -07:00
ti_hecc.c Fix some #includes in CAN drivers (rebased for net-next-2.6) 2010-04-13 03:32:42 -07:00
vcan.c include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h 2010-03-30 22:02:32 +09:00