[PATCH] ARM: keystone: Fix OF node reference leak in keystone_pm_runtime_init()

Andrew Davis afd at ti.com
Thu Dec 3 08:09:46 PST 2026


On 11/24/26 9:46 AM, Yuho Choi wrote:
> 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.
> 
> Fixes: 8620d2c536dc ("ARM: keystone: fix PM domain initcall to be keystone only")
> Signed-off-by: Yuho Choi <oss.patchbox at gmail.com>
> ---

Acked-by: Andrew Davis <afd at ti.com>

> 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(-)
> 
> diff --git a/arch/arm/mach-keystone/keystone.c b/arch/arm/mach-keystone/keystone.c
> index f63671a3024c..4e1f02a73887 100644
> --- a/arch/arm/mach-keystone/keystone.c
> +++ b/arch/arm/mach-keystone/keystone.c
> @@ -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




More information about the linux-arm-kernel mailing list