kernel_optimize_test/arch/powerpc/sysdev
Julia Lawall b1725c9319 [POWERPC] arch/powerpc/sysdev: Add missing of_node_put
The functions of_find_compatible_node and of_find_node_by_type both
call of_node_get on their result.  So any error handling code
thereafter should call of_node_put(np).  This is taken care of in the
case where there is a goto out, but not when there is a direct return.

The function irq_alloc_host puts np into the returned structure, which is
stored in the global variable mpc8xx_pic_host, so the reference count
should be set for the lifetime of that variable.  The current solution ups
the reference count again in the argument to irq_alloc_host so that it can
be decremented on the way out.  This seems a bit unnecessary, and also
doesn't work in the case where irq_alloc_host fails, because then the
reference count only goes does by one, whereas it should go down by two.  A
better solution is to not increment the reference count in the argument to
irq_alloc_host and only decrement it on the way out in an error case.

The problem was found using the following semantic match.
(http://www.emn.fr/x-info/coccinelle/)

// <smpl>
@@
type T,T1,T2;
identifier E;
statement S;
expression x1,x2,x3;
int ret;
@@

  T E;
  ...
* E = \(of_get_parent\|of_find_compatible_node\)(...);
  if (E == NULL) S
  ... when != of_node_put(...,(T1)E,...)
      when != if (E != NULL) { ... of_node_put(...,(T1)E,...); ...}
      when != x1 = (T1)E
      when != E = x3;
      when any
  if (...) {
    ... when != of_node_put(...,(T2)E,...)
        when != if (E != NULL) { ... of_node_put(...,(T2)E,...); ...}
        when != x2 = (T2)E
(
*   return;
|
*   return ret;
)
  }
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Kumar Gala <galak@gate.crashing.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Paul Mackerras <paulus@samba.org>
2008-02-06 22:06:59 +11:00
..
bestcomm [POWERPC] mpc5200: normalize compatible property bindings 2008-01-26 15:26:01 -07:00
qe_lib Merge branch 'linux-2.6' 2008-01-31 11:25:51 +11:00
axonram.c [POWERPC] Clean out asm/of_{platform, device}.h from sysdev/ 2007-12-06 14:44:30 +11:00
cpm1.c [POWERPC] CPM: Rename commproc to cpm1 and cpm2_common.c to cpm2.c 2008-01-28 08:31:05 -06:00
cpm2_pic.c [POWERPC] cpm2: Infrastructure code cleanup. 2007-10-04 11:02:04 -05:00
cpm2_pic.h
cpm2.c [POWERPC] CPM: Rename commproc to cpm1 and cpm2_common.c to cpm2.c 2008-01-28 08:31:05 -06:00
cpm_common.c [POWERPC] cpm: Fix a couple minor issues in cpm_common.c. 2007-11-09 03:47:44 -06:00
dart_iommu.c [POWERPC] Fix section mismatch in dart_iommu.c 2007-08-17 11:02:06 +10:00
dart.h
dcr-low.S
dcr.c Use dcr_host_t.base in dcr_unmap() 2007-10-15 14:29:49 -04:00
fsl_pci.c [POWERPC] FSL: Rework PCI/PCIe support for 85xx/86xx 2008-01-23 19:31:16 -06:00
fsl_pci.h [POWERPC] Fixup resources on pci_bus for PCIe PHB when no device is connected 2007-07-23 10:27:08 -05:00
fsl_rio.c [POWERPC] Move RapidIO support code from arch/ppc 2008-01-23 19:35:15 -06:00
fsl_rio.h [POWERPC] Move RapidIO support code from arch/ppc 2008-01-23 19:35:15 -06:00
fsl_soc.c [POWERPC] fsl_spi: stop using device_type = "spi" 2008-01-28 08:32:58 -06:00
fsl_soc.h [POWERPC] 85xx/86xx: refactor RSTCR reset code 2007-10-08 08:38:47 -05:00
grackle.c [POWERPC] pci32: Add flags modifying the PCI code behaviour 2007-12-20 16:18:07 +11:00
i8259.c [POWERPC] i8259: Add disable method 2007-11-08 14:15:29 +11:00
indirect_pci.c [POWERPC] PCI: Add 64-bit physical address support to setup_indirect_pci 2007-10-12 14:05:17 +10:00
ipic.c Merge branch 'linux-2.6' 2008-01-31 11:25:51 +11:00
ipic.h [POWERPC] ipic: ack only for edge interrupts 2007-12-12 01:53:07 -06:00
Kconfig [POWERPC] 4xx: PLB to PCI Express support 2007-12-23 13:12:34 -06:00
Makefile [POWERPC] CPM: Rename commproc to cpm1 and cpm2_common.c to cpm2.c 2008-01-28 08:31:05 -06:00
micropatch.c [POWERPC] CPM: Rename commproc to cpm1 and cpm2_common.c to cpm2.c 2008-01-28 08:31:05 -06:00
mmio_nvram.c [POWERPC] arch/powerpc/: Spelling fixes 2007-12-20 16:15:51 +11:00
mpc8xx_pic.c [POWERPC] arch/powerpc/sysdev: Add missing of_node_put 2008-02-06 22:06:59 +11:00
mpc8xx_pic.h [POWERPC] 8xx: mpc885ads pcmcia support 2007-07-10 00:33:51 -05:00
mpic_msi.c [POWERPC] Fix section mismatch in PCI code 2007-09-19 15:25:34 +10:00
mpic_pasemi_msi.c [POWERPC] pasemi: Implement MSI support 2007-12-20 16:15:23 +11:00
mpic_u3msi.c [POWERPC] Inline u3msi_compose_msi_msg() 2007-10-03 09:11:42 +10:00
mpic.c Merge branch 'linux-2.6' 2008-01-31 11:25:51 +11:00
mpic.h [POWERPC] pasemi: Implement NMI support 2007-12-28 09:22:24 -06:00
mv64x60_dev.c Merge branch 'linux-2.6' 2008-01-31 11:25:51 +11:00
mv64x60_pci.c [POWERPC] Use for_each macros in arch/powerpc/sysdev 2008-01-17 14:56:54 +11:00
mv64x60_pic.c [POWERPC] Provide a default irq_host match, which matches on an exact of_node 2007-09-14 01:33:20 +10:00
mv64x60_udbg.c [POWERPC] Use for_each macros in arch/powerpc/sysdev 2008-01-17 14:56:54 +11:00
mv64x60.h [POWERPC] Add Marvell mv64x60 udbg putc/getc functions 2007-09-22 14:49:21 +10:00
of_rtc.c [POWERPC] Enable RTC for Ebony and Walnut (v2) 2008-01-25 07:07:26 -06:00
pmi.c [POWERPC] Clean out asm/of_{platform, device}.h from sysdev/ 2007-12-06 14:44:30 +11:00
ppc4xx_pci.c [POWERPC] 4xx: PCIe: Increase max busses per port to 64 2008-01-08 08:05:23 -06:00
ppc4xx_pci.h [POWERPC] 4xx: PCI-E Link setup improvements 2007-12-23 13:18:49 -06:00
rtc_cmos_setup.c [POWERPC] Add interrupt resource for RTC CMOS driver 2007-08-17 13:18:58 -05:00
tsi108_dev.c [POWERPC] Use for_each macros in arch/powerpc/sysdev 2008-01-17 14:56:54 +11:00
tsi108_pci.c [POWERPC] Provide a default irq_host match, which matches on an exact of_node 2007-09-14 01:33:20 +10:00
uic.c [POWERPC] Use for_each macros in arch/powerpc/sysdev 2008-01-17 14:56:54 +11:00
xilinx_intc.c [POWERPC] Xilinx: update compatible list for interrupt controller 2008-01-09 07:48:31 -07:00