linux/drivers/of
Ma Ke f112154107 of: unittest: Fix device reference count leak in of_unittest_pci_node_verify
commit a8de554774 upstream.

In of_unittest_pci_node_verify(), when the add parameter is false,
device_find_any_child() obtains a reference to a child device. This
function implicitly calls get_device() to increment the device's
reference count before returning the pointer. However, the caller
fails to properly release this reference by calling put_device(),
leading to a device reference count leak. Add put_device() in the else
branch immediately after child_dev is no longer needed.

As the comment of device_find_any_child states: "NOTE: you will need
to drop the reference with put_device() after use".

Found by code review.

Cc: stable@vger.kernel.org
Fixes: 26409dd045 ("of: unittest: Add pci_dt_testdrv pci driver")
Signed-off-by: Ma Ke <make24@iscas.ac.cn>
Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
History 2025-10-19 16:33:51 +02:00
..
unittest-data of/unittest: Add test that of_address_to_resource() fails on non-translatable address 2025-02-01 18:39:35 +01:00
.kunitconfig of: Add a KUnit test for overlays and test managed APIs 2024-07-29 15:33:12 -07:00
address.c of: address: Fix empty resource handling in __of_address_resource_bounds() 2025-02-17 10:05:13 +01:00
base.c of: Fix of_find_node_opts_by_path() handling of alias+path+options 2025-02-17 10:05:13 +01:00
cpu.c of: Move CPU node related functions to their own file 2023-04-13 17:46:34 -05:00
device.c OF: Simplify of_iommu_configure() 2024-07-04 14:36:04 +01:00
dynamic.c of: dynamic: Fix use after free in of_changeset_add_prop_helper() 2025-09-04 15:31:43 +02:00
empty_root.dts of: Create of_root if no dtb provided by firmware 2024-03-08 12:50:39 -06:00
fdt.c of/fdt: Restore possibility to use both ACPI and FDT from bootloader 2025-02-08 09:57:52 +01:00
fdt_address.c of: Use SPDX license tag for DT files 2018-01-08 08:22:45 -06:00
irq.c of/irq: Fix device node refcount leakages in of_irq_init() 2025-04-20 10:15:57 +02:00
Kconfig of: Add a KUnit test for overlays and test managed APIs 2024-07-29 15:33:12 -07:00
kexec.c of/fdt: add dt_phys arg to early_init_dt_scan and early_init_dt_verify 2024-12-05 14:01:32 +01:00
kobj.c of: make of_node_ktype constant 2023-02-06 11:03:00 -06:00
kunit_overlay_test.dtso of: Add a KUnit test for overlays and test managed APIs 2024-07-29 15:33:12 -07:00
Makefile of: Add a KUnit test for overlays and test managed APIs 2024-07-29 15:33:12 -07:00
module.c Devicetree for v6.10: 2024-05-17 17:27:49 -07:00
of_kunit_helpers.c of: Skip kunit tests when arm64+ACPI doesn't populate root node 2024-10-10 12:43:01 -05:00
of_numa.c of_numa: fix uninitialized memory nodes causing kernel panic 2025-09-09 18:58:16 +02:00
of_private.h of: reserved_mem: Restructure how the reserved memory regions are processed 2025-02-08 09:57:52 +01:00
of_reserved_mem.c of: reserved_mem: Restructure call site for dma_contiguous_early_fixup() 2025-09-04 15:31:45 +02:00
of_test.c of: Skip kunit tests when arm64+ACPI doesn't populate root node 2024-10-10 12:43:01 -05:00
overlay.c of: overlay: Simplify with scoped for each OF child loop 2024-08-26 10:50:46 -05:00
overlay_test.c of: Skip kunit tests when arm64+ACPI doesn't populate root node 2024-10-10 12:43:01 -05:00
pdt.c of: Remove struct device_node.type pointer 2019-01-10 16:24:44 -06:00
platform.c The core clk framework is left largely untouched this time around except for 2024-09-23 15:01:48 -07:00
property.c of: property: Avoiding using uninitialized variable @imaplen in parse_interrupt_map() 2025-02-08 09:57:51 +01:00
resolver.c of: resolver: Fix device node refcount leakage in of_resolve_phandles() 2025-05-02 07:58:55 +02:00
unittest.c of: unittest: Fix device reference count leak in of_unittest_pci_node_verify 2025-10-19 16:33:51 +02:00