linux/drivers/of
Frank Rowand d9fc880723 of: fix memory leak related to safe_name()
Fix a memory leak resulting from memory allocation in safe_name().
This patch fixes all call sites of safe_name().

Mathieu Malaterre reported the memory leak on boot:

On my PowerMac device-tree would generate a duplicate name:

[    0.023043] device-tree: Duplicate name in PowerPC,G4@0, renamed to "l2-cache#1"

in this case a newly allocated name is generated by `safe_name`. However
in this case it is never deallocated.

The bug was found using kmemleak reported as:

unreferenced object 0xdf532e60 (size 32):
  comm "swapper", pid 1, jiffies 4294892300 (age 1993.532s)
  hex dump (first 32 bytes):
    6c 32 2d 63 61 63 68 65 23 31 00 dd e4 dd 1e c2  l2-cache#1......
    ec d4 ba ce 04 ec cc de 8e 85 e9 ca c4 ec cc 9e  ................
  backtrace:
    [<c02d3350>] kvasprintf+0x64/0xc8
    [<c02d3400>] kasprintf+0x4c/0x5c
    [<c0453814>] safe_name.isra.1+0x80/0xc4
    [<c04545d8>] __of_attach_node_sysfs+0x6c/0x11c
    [<c075f21c>] of_core_init+0x8c/0xf8
    [<c0729594>] kernel_init_freeable+0xd4/0x208
    [<c00047e8>] kernel_init+0x24/0x11c
    [<c00158ec>] ret_from_kernel_thread+0x5c/0x64

Link: https://bugzilla.kernel.org/show_bug.cgi?id=120331

Signed-off-by: Frank Rowand <frank.rowand@am.sony.com>
Reported-by: mathieu.malaterre@gmail.com
Tested-by: Mathieu Malaterre <mathieu.malaterre@gmail.com>
Cc: stable@vger.kernel.org
Signed-off-by: Rob Herring <robh@kernel.org>
2016-06-24 15:16:10 -05:00
..
unittest-data
address.c PCI, of: Move PCI I/O space management to PCI core code 2016-05-12 07:07:42 -05:00
base.c of: fix memory leak related to safe_name() 2016-06-24 15:16:10 -05:00
device.c iommu: of: enforce const-ness of struct iommu_ops 2016-05-09 15:33:29 +02:00
dynamic.c of: fix memory leak related to safe_name() 2016-06-24 15:16:10 -05:00
fdt_address.c of: earlycon: Move address translation to of_setup_earlycon() 2016-02-06 22:07:37 -08:00
fdt.c drivers/of: Fix depth for sub-tree blob in unflatten_dt_nodes() 2016-06-09 14:36:34 -05:00
irq.c of: irq: fix of_irq_get[_byname]() kernel-doc 2016-06-03 07:22:01 -05:00
Kconfig of, numa: Add NUMA of binding implementation. 2016-04-15 18:06:08 +01:00
Makefile MTD updates for v4.7: 2016-05-24 11:00:20 -07:00
of_mdio.c of: of_mdio: Check if MDIO bus controller is available 2016-05-01 19:34:29 -04:00
of_net.c
of_numa.c of, numa: Add NUMA of binding implementation. 2016-04-15 18:06:08 +01:00
of_pci_irq.c of_pci_irq: Silence bogus "of_irq_parse_pci() failed ..." messages. 2015-09-17 14:46:11 -05:00
of_pci.c PCI: Remove includes of empty asm-generic/pci-bridge.h 2016-02-05 16:28:36 -06:00
of_private.h of: fix memory leak related to safe_name() 2016-06-24 15:16:10 -05:00
of_reserved_mem.c of: silence warnings due to max() usage 2016-06-03 07:25:38 -05:00
overlay.c drivers/of: Export OF changeset functions 2016-01-13 16:10:37 -06:00
pdt.c
platform.c Revert "of/platform: export of_default_bus_match_table" 2016-06-23 15:01:02 -05:00
resolver.c of: resolver: Add missing of_node_get and of_node_put 2016-02-13 13:35:32 -06:00
unittest.c of: unittest: use of_platform_default_populate() to populate default bus 2016-06-23 15:00:59 -05:00