* [PATCH 0/2] ARM: highbank: add missing of_node_put calls
@ 2022-12-18 14:26 Martin Kaiser
2022-12-18 14:26 ` [PATCH 1/2] ARM: highbank: add missing of_node_put call Martin Kaiser
2022-12-18 14:26 ` [PATCH 2/2] ARM: highbank: fix of node handling in highbank_init_irq Martin Kaiser
0 siblings, 2 replies; 5+ messages in thread
From: Martin Kaiser @ 2022-12-18 14:26 UTC (permalink / raw)
To: Andre Przywara
Cc: Martin Kaiser, Russell King, linux-arm-kernel, linux-kernel
Here's two simple patches to call of_node_put for device nodes that were
returned by of_find_compatible_node.
Both patches were compile-tested only as I don't have the hardware to run
the code.
Martin Kaiser (2):
ARM: highbank: add missing of_node_put call
ARM: highbank: fix of node handling in highbank_init_irq
arch/arm/mach-highbank/highbank.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
--
2.30.2
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] ARM: highbank: add missing of_node_put call
2022-12-18 14:26 [PATCH 0/2] ARM: highbank: add missing of_node_put calls Martin Kaiser
@ 2022-12-18 14:26 ` Martin Kaiser
2022-12-20 13:32 ` Andre Przywara
2022-12-18 14:26 ` [PATCH 2/2] ARM: highbank: fix of node handling in highbank_init_irq Martin Kaiser
1 sibling, 1 reply; 5+ messages in thread
From: Martin Kaiser @ 2022-12-18 14:26 UTC (permalink / raw)
To: Andre Przywara, Russell King
Cc: Martin Kaiser, linux-arm-kernel, linux-kernel
A node that is returned by of_find_compatible_node has its refcount
incremented. We have to call of_node_put when the node is no longer
needed.
Add a missing of_node_put call in function highbank_init.
Signed-off-by: Martin Kaiser <martin@kaiser.cx>
---
arch/arm/mach-highbank/highbank.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/arm/mach-highbank/highbank.c b/arch/arm/mach-highbank/highbank.c
index 5d4f977ac7d2..97ccb8c1b3cd 100644
--- a/arch/arm/mach-highbank/highbank.c
+++ b/arch/arm/mach-highbank/highbank.c
@@ -141,6 +141,7 @@ static void __init highbank_init(void)
/* Map system registers */
np = of_find_compatible_node(NULL, NULL, "calxeda,hb-sregs");
sregs_base = of_iomap(np, 0);
+ of_node_put(np);
WARN_ON(!sregs_base);
pm_power_off = highbank_power_off;
--
2.30.2
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] ARM: highbank: add missing of_node_put call
2022-12-18 14:26 ` [PATCH 1/2] ARM: highbank: add missing of_node_put call Martin Kaiser
@ 2022-12-20 13:32 ` Andre Przywara
0 siblings, 0 replies; 5+ messages in thread
From: Andre Przywara @ 2022-12-20 13:32 UTC (permalink / raw)
To: Martin Kaiser
Cc: Russell King, linux-arm-kernel, linux-kernel, lv.ruyi, cgel.zte
On Sun, 18 Dec 2022 15:26:46 +0100
Martin Kaiser <martin@kaiser.cx> wrote:
Hi Martin,
> A node that is returned by of_find_compatible_node has its refcount
> incremented. We have to call of_node_put when the node is no longer
> needed.
>
> Add a missing of_node_put call in function highbank_init.
Thanks for the patch.
So Ruyi sent the exact same one earlier this year already:
https://lore.kernel.org/linux-arm-kernel/20220408094817.2494756-1-lv.ruyi@zte.com.cn/
I asked Arnd and Olof to take it back then (see my reply), but this somehow
got lost.
I will try to push on both Ruyi's and your second patch again - but I
guess only after the holidays.
Cheers,
Andre
> Signed-off-by: Martin Kaiser <martin@kaiser.cx>
> ---
> arch/arm/mach-highbank/highbank.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/arch/arm/mach-highbank/highbank.c b/arch/arm/mach-highbank/highbank.c
> index 5d4f977ac7d2..97ccb8c1b3cd 100644
> --- a/arch/arm/mach-highbank/highbank.c
> +++ b/arch/arm/mach-highbank/highbank.c
> @@ -141,6 +141,7 @@ static void __init highbank_init(void)
> /* Map system registers */
> np = of_find_compatible_node(NULL, NULL, "calxeda,hb-sregs");
> sregs_base = of_iomap(np, 0);
> + of_node_put(np);
> WARN_ON(!sregs_base);
>
> pm_power_off = highbank_power_off;
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2/2] ARM: highbank: fix of node handling in highbank_init_irq
2022-12-18 14:26 [PATCH 0/2] ARM: highbank: add missing of_node_put calls Martin Kaiser
2022-12-18 14:26 ` [PATCH 1/2] ARM: highbank: add missing of_node_put call Martin Kaiser
@ 2022-12-18 14:26 ` Martin Kaiser
2022-12-20 13:25 ` Andre Przywara
1 sibling, 1 reply; 5+ messages in thread
From: Martin Kaiser @ 2022-12-18 14:26 UTC (permalink / raw)
To: Andre Przywara, Russell King
Cc: Martin Kaiser, linux-arm-kernel, linux-kernel
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 <martin@kaiser.cx>
---
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
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH 2/2] ARM: highbank: fix of node handling in highbank_init_irq
2022-12-18 14:26 ` [PATCH 2/2] ARM: highbank: fix of node handling in highbank_init_irq Martin Kaiser
@ 2022-12-20 13:25 ` Andre Przywara
0 siblings, 0 replies; 5+ messages in thread
From: Andre Przywara @ 2022-12-20 13:25 UTC (permalink / raw)
To: Martin Kaiser; +Cc: Russell King, linux-arm-kernel, linux-kernel
On Sun, 18 Dec 2022 15:26:47 +0100
Martin Kaiser <martin@kaiser.cx> 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 <martin@kaiser.cx>
> ---
> 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 <andre.przywara@arm.com>
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)
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-12-20 13:32 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-18 14:26 [PATCH 0/2] ARM: highbank: add missing of_node_put calls Martin Kaiser
2022-12-18 14:26 ` [PATCH 1/2] ARM: highbank: add missing of_node_put call Martin Kaiser
2022-12-20 13:32 ` Andre Przywara
2022-12-18 14:26 ` [PATCH 2/2] ARM: highbank: fix of node handling in highbank_init_irq Martin Kaiser
2022-12-20 13:25 ` Andre Przywara
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®