ARM: keystone: Fix OF node reference leak in keystone_pm_runtime_init()
PATCH 1/1 ARM: keystone: Fix OF node reference leak in keystone_pm_runtime_init()
keystone_pm_runtime_init() calls of_find_matching_node() only to check whether it runs on a K2HK, K2E or K2L SoC. The node it finds is returned with its reference count raised, but the function only tests the pointer and never drops that reference. keystone_init() calls it once at boot, so a single reference is leaked.
The compatibles in of_keystone_table are only used on the root node, so use of_machine_device_match(), which checks the root node without leaving a reference behind.
---
Compile-tested only (ARM multi_v7_defconfig, W=1). I have no Keystone board to test it on. All uses of the "ti,k2hk", "ti,k2e" and "ti,k2l" compatibles in arch/arm/boot/dts are on the root node.
arch/arm/mach-keystone/keystone.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
arch/arm/mach-keystone/keystone.c +1 -4
@@ -53,10 +53,7 @@ static const struct of_device_id of_keystone_table[] = {static int __init keystone_pm_runtime_init (void ) { -struct device_node *np; - - np =of_find_matching_node (NULL , of_keystone_table); -if (!np) +if (!of_machine_device_match (of_keystone_table))return 0 ;pm_clk_add_notifier (&platform_bus_type, &platform_domain_notifier);
base-commit: 8dac6df92a2e66e2098bbc69061964cfe7e8375b
Signature · 1 line
2.56.1