2022-12-18 14:30:44

by Martin Kaiser

[permalink] [raw]
Subject: [PATCH 2/2] ARM: highbank: fix of node handling in highbank_init_irq

highbank_init calls of_find_compatible_node and discards the returned
node. We should save the node and call of_node_put on it when finished.

Signed-off-by: Martin Kaiser <[email protected]>
---
arch/arm/mach-highbank/highbank.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-highbank/highbank.c b/arch/arm/mach-highbank/highbank.c
index 97ccb8c1b3cd..54eb1422ef8f 100644
--- a/arch/arm/mach-highbank/highbank.c
+++ b/arch/arm/mach-highbank/highbank.c
@@ -50,10 +50,16 @@ static void highbank_l2c310_write_sec(unsigned long val, unsigned reg)

static void __init highbank_init_irq(void)
{
+ struct device_node *np;
+
irqchip_init();

- if (of_find_compatible_node(NULL, NULL, "arm,cortex-a9"))
- highbank_scu_map_io();
+ np = of_find_compatible_node(NULL, NULL, "arm,cortex-a9");
+ if (!np)
+ return;
+
+ highbank_scu_map_io();
+ of_node_put(np);
}

static void highbank_power_off(void)
--
2.30.2


2022-12-20 13:43:54

by Andre Przywara

[permalink] [raw]
Subject: Re: [PATCH 2/2] ARM: highbank: fix of node handling in highbank_init_irq

On Sun, 18 Dec 2022 15:26:47 +0100
Martin Kaiser <[email protected]> wrote:

Hi Martin,

thanks for taking care of this.

> highbank_init calls of_find_compatible_node and discards the returned
> node. We should save the node and call of_node_put on it when finished.
>
> Signed-off-by: Martin Kaiser <[email protected]>
> ---
> arch/arm/mach-highbank/highbank.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm/mach-highbank/highbank.c b/arch/arm/mach-highbank/highbank.c
> index 97ccb8c1b3cd..54eb1422ef8f 100644
> --- a/arch/arm/mach-highbank/highbank.c
> +++ b/arch/arm/mach-highbank/highbank.c
> @@ -50,10 +50,16 @@ static void highbank_l2c310_write_sec(unsigned long val, unsigned reg)
>
> static void __init highbank_init_irq(void)
> {
> + struct device_node *np;
> +
> irqchip_init();
>
> - if (of_find_compatible_node(NULL, NULL, "arm,cortex-a9"))
> - highbank_scu_map_io();
> + np = of_find_compatible_node(NULL, NULL, "arm,cortex-a9");
> + if (!np)
> + return;
> +
> + highbank_scu_map_io();
> + of_node_put(np);

Technically the of_node_put() could happen even earlier, since we
use the of_find_compatible_node() call only to figure out if this is the
Cotex-A15 or the A9 part. But it doesn't really matter, and is correct
anyways:

Reviewed-by: Andre Przywara <[email protected]>

I also quickly boot tested this on a Midway(A15), but don't have a
Highbank(A9) readily set up at the moment.

Cheers,
Andre


> }
>
> static void highbank_power_off(void)