* [PATCH 0/6] add missing of_node_put
@ 2015-11-20 20:33 Julia Lawall
2015-11-20 20:33 ` [PATCH 1/6] powerpc/6xx: " Julia Lawall
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: Julia Lawall @ 2015-11-20 20:33 UTC (permalink / raw)
To: Benjamin Herrenschmidt
Cc: kernel-janitors, Paul Mackerras, Michael Ellerman, linuxppc-dev,
linux-kernel
The various for_each device_node iterators performs an of_node_get on each
iteration, so a break out of the loop requires an of_node_put.
The complete semantic patch that fixes this problem is
(http://coccinelle.lip6.fr):
// <smpl>
@r@
local idexpression n;
expression e1,e2;
iterator name for_each_node_by_name, for_each_node_by_type,
for_each_compatible_node, for_each_matching_node,
for_each_matching_node_and_match, for_each_child_of_node,
for_each_available_child_of_node, for_each_node_with_property;
iterator i;
statement S;
expression list [n1] es;
@@
(
(
for_each_node_by_name(n,e1) S
|
for_each_node_by_type(n,e1) S
|
for_each_compatible_node(n,e1,e2) S
|
for_each_matching_node(n,e1) S
|
for_each_matching_node_and_match(n,e1,e2) S
|
for_each_child_of_node(e1,n) S
|
for_each_available_child_of_node(e1,n) S
|
for_each_node_with_property(n,e1) S
)
&
i(es,n,...) S
)
@@
local idexpression r.n;
iterator r.i;
expression e;
expression list [r.n1] es;
@@
i(es,n,...) {
...
(
of_node_put(n);
|
e = n
|
return n;
|
+ of_node_put(n);
? return ...;
)
...
}
@@
local idexpression r.n;
iterator r.i;
expression e;
expression list [r.n1] es;
@@
i(es,n,...) {
...
(
of_node_put(n);
|
e = n
|
+ of_node_put(n);
? break;
)
...
}
... when != n
@@
local idexpression r.n;
iterator r.i;
expression e;
identifier l;
expression list [r.n1] es;
@@
i(es,n,...) {
...
(
of_node_put(n);
|
e = n
|
+ of_node_put(n);
? goto l;
)
...
}
...
l: ... when != n// </smpl>
---
arch/powerpc/kernel/btext.c | 4 +++-
arch/powerpc/kernel/machine_kexec_64.c | 4 +++-
arch/powerpc/platforms/cell/iommu.c | 1 +
arch/powerpc/platforms/embedded6xx/hlwd-pic.c | 1 +
arch/powerpc/platforms/powernv/opal-lpc.c | 1 +
arch/powerpc/platforms/pseries/setup.c | 3 ++-
6 files changed, 11 insertions(+), 3 deletions(-)
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/6] powerpc/6xx: add missing of_node_put
2015-11-20 20:33 [PATCH 0/6] add missing of_node_put Julia Lawall
@ 2015-11-20 20:33 ` Julia Lawall
2015-11-20 20:33 ` [PATCH 2/6] powerpc/pseries: " Julia Lawall
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Julia Lawall @ 2015-11-20 20:33 UTC (permalink / raw)
To: Benjamin Herrenschmidt
Cc: kernel-janitors, Paul Mackerras, Michael Ellerman, linuxppc-dev,
linux-kernel, Russell King - ARM Linux, Thomas Petazzoni,
Andrew Lunn, Bjorn Helgaas, Jason Cooper
for_each_compatible_node performs an of_node_get on each iteration, so
a break out of the loop requires an of_node_put.
A simplified version of the semantic patch that fixes this problem is as
follows (http://coccinelle.lip6.fr):
// <smpl>
@@
expression e;
local idexpression n;
@@
@@
local idexpression n;
expression e;
@@
for_each_compatible_node(n,...) {
...
(
of_node_put(n);
|
e = n
|
+ of_node_put(n);
? break;
)
...
}
... when != n
// </smpl>
Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
---
arch/powerpc/platforms/embedded6xx/hlwd-pic.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/powerpc/platforms/embedded6xx/hlwd-pic.c b/arch/powerpc/platforms/embedded6xx/hlwd-pic.c
index 9b79757..b581b42 100644
--- a/arch/powerpc/platforms/embedded6xx/hlwd-pic.c
+++ b/arch/powerpc/platforms/embedded6xx/hlwd-pic.c
@@ -215,6 +215,7 @@ void hlwd_pic_probe(void)
irq_set_chained_handler(cascade_virq,
hlwd_pic_irq_cascade);
hlwd_irq_host = host;
+ of_node_put(np);
break;
}
}
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/6] powerpc/pseries: add missing of_node_put
2015-11-20 20:33 [PATCH 0/6] add missing of_node_put Julia Lawall
2015-11-20 20:33 ` [PATCH 1/6] powerpc/6xx: " Julia Lawall
@ 2015-11-20 20:33 ` Julia Lawall
2015-11-20 20:33 ` [PATCH 3/6] powerpc/powernv: " Julia Lawall
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Julia Lawall @ 2015-11-20 20:33 UTC (permalink / raw)
To: Benjamin Herrenschmidt
Cc: kernel-janitors, Paul Mackerras, Michael Ellerman, linuxppc-dev,
linux-kernel, Russell King - ARM Linux, Thomas Petazzoni,
Andrew Lunn, Bjorn Helgaas, Jason Cooper
for_each_node_by_type performs an of_node_get on each iteration, so a break
out of the loop requires an of_node_put. In this code, there are two paths
that break out of the loop. In the first one (open-pic case), the code
originally contained an of_node_get. That increments the reference count,
which cancels out against the decrement of the reference count that is
needed here, and thus the patch drops the of_node_get. In the second one
(ppc-xicp case), there is no need to save the node value, and so an
of_node_put is added as described by the following semantic patch rule
(http://coccinelle.lip6.fr):
// <smpl>
@@
expression e,e1;
local idexpression n;
@@
for_each_node_by_type(n, e1) {
... when != of_node_put(n)
when != e = n
(
return n;
|
+ of_node_put(n);
? return ...;
)
...
}
// </smpl>
Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
---
arch/powerpc/platforms/pseries/setup.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c
index 36df46e..7185cd3 100644
--- a/arch/powerpc/platforms/pseries/setup.c
+++ b/arch/powerpc/platforms/pseries/setup.c
@@ -236,7 +236,7 @@ static void __init pseries_discover_pic(void)
for_each_node_by_name(np, "interrupt-controller") {
typep = of_get_property(np, "compatible", NULL);
if (strstr(typep, "open-pic")) {
- pSeries_mpic_node = of_node_get(np);
+ pSeries_mpic_node = np;
ppc_md.init_IRQ = pseries_mpic_init_IRQ;
setup_kexec_cpu_down_mpic();
smp_init_pseries_mpic();
@@ -245,6 +245,7 @@ static void __init pseries_discover_pic(void)
ppc_md.init_IRQ = pseries_xics_init_IRQ;
setup_kexec_cpu_down_xics();
smp_init_pseries_xics();
+ of_node_put(np);
return;
}
}
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 3/6] powerpc/powernv: add missing of_node_put
2015-11-20 20:33 [PATCH 0/6] add missing of_node_put Julia Lawall
2015-11-20 20:33 ` [PATCH 1/6] powerpc/6xx: " Julia Lawall
2015-11-20 20:33 ` [PATCH 2/6] powerpc/pseries: " Julia Lawall
@ 2015-11-20 20:33 ` Julia Lawall
2015-11-20 20:33 ` [PATCH 4/6] powerpc/kexec: " Julia Lawall
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Julia Lawall @ 2015-11-20 20:33 UTC (permalink / raw)
To: Benjamin Herrenschmidt
Cc: kernel-janitors, Paul Mackerras, Michael Ellerman, linuxppc-dev,
linux-kernel, Russell King - ARM Linux, Thomas Petazzoni,
Andrew Lunn, Bjorn Helgaas, Jason Cooper
for_each_compatible_node performs an of_node_get on each iteration, so
a break out of the loop requires an of_node_put.
A simplified version of the semantic patch that fixes this problem is as
follows (http://coccinelle.lip6.fr):
// <smpl>
@@
local idexpression n;
expression e;
@@
for_each_compatible_node(n,...) {
...
(
of_node_put(n);
|
e = n
|
+ of_node_put(n);
? break;
)
...
}
... when != n
// </smpl>
Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
---
arch/powerpc/platforms/powernv/opal-lpc.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/powerpc/platforms/powernv/opal-lpc.c b/arch/powerpc/platforms/powernv/opal-lpc.c
index e4169d6..d28c4a9 100644
--- a/arch/powerpc/platforms/powernv/opal-lpc.c
+++ b/arch/powerpc/platforms/powernv/opal-lpc.c
@@ -401,6 +401,7 @@ void opal_lpc_init(void)
if (!of_get_property(np, "primary", NULL))
continue;
opal_lpc_chip_id = of_get_ibm_chip_id(np);
+ of_node_put(np);
break;
}
if (opal_lpc_chip_id < 0)
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 4/6] powerpc/kexec: add missing of_node_put
2015-11-20 20:33 [PATCH 0/6] add missing of_node_put Julia Lawall
` (2 preceding siblings ...)
2015-11-20 20:33 ` [PATCH 3/6] powerpc/powernv: " Julia Lawall
@ 2015-11-20 20:33 ` Julia Lawall
2015-11-20 20:33 ` [PATCH 5/6] powerpc/btext: " Julia Lawall
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Julia Lawall @ 2015-11-20 20:33 UTC (permalink / raw)
To: Benjamin Herrenschmidt
Cc: kernel-janitors, Paul Mackerras, Michael Ellerman, linuxppc-dev,
linux-kernel, Russell King - ARM Linux, Thomas Petazzoni,
Andrew Lunn, Bjorn Helgaas, Jason Cooper
for_each_node_by_type performs an of_node_get on each iteration, so
a break out of the loop requires an of_node_put.
A simplified version of the semantic patch that fixes this problem is as
follows (http://coccinelle.lip6.fr):
// <smpl>
@@
expression e,e1;
local idexpression n;
@@
for_each_node_by_type(n, e1) {
... when != of_node_put(n)
when != e = n
(
return n;
|
+ of_node_put(n);
? return ...;
)
...
}
// </smpl>
Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
---
arch/powerpc/kernel/machine_kexec_64.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/arch/powerpc/kernel/machine_kexec_64.c b/arch/powerpc/kernel/machine_kexec_64.c
index 0fbd75d..4ba61ce 100644
--- a/arch/powerpc/kernel/machine_kexec_64.c
+++ b/arch/powerpc/kernel/machine_kexec_64.c
@@ -103,8 +103,10 @@ int default_machine_kexec_prepare(struct kimage *image)
begin = image->segment[i].mem;
end = begin + image->segment[i].memsz;
- if ((begin < high) && (end > low))
+ if ((begin < high) && (end > low)) {
+ of_node_put(node);
return -ETXTBSY;
+ }
}
}
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 5/6] powerpc/btext: add missing of_node_put
2015-11-20 20:33 [PATCH 0/6] add missing of_node_put Julia Lawall
` (3 preceding siblings ...)
2015-11-20 20:33 ` [PATCH 4/6] powerpc/kexec: " Julia Lawall
@ 2015-11-20 20:33 ` Julia Lawall
2015-11-20 20:33 ` [PATCH 6/6] powerpc/cell: " Julia Lawall
2021-11-25 9:35 ` (subset) [PATCH 0/6] " Michael Ellerman
6 siblings, 0 replies; 8+ messages in thread
From: Julia Lawall @ 2015-11-20 20:33 UTC (permalink / raw)
To: Benjamin Herrenschmidt
Cc: kernel-janitors, Paul Mackerras, Michael Ellerman, linuxppc-dev,
linux-kernel, Russell King - ARM Linux, Thomas Petazzoni,
Andrew Lunn, Bjorn Helgaas, Jason Cooper
for_each_node_by_type performs an of_node_get on each iteration, so
a break out of the loop requires an of_node_put.
A simplified version of the semantic patch that fixes this problem is as
follows (http://coccinelle.lip6.fr):
// <smpl>
@@
local idexpression n;
expression e;
@@
for_each_node_by_type(n,...) {
...
(
of_node_put(n);
|
e = n
|
+ of_node_put(n);
? break;
)
...
}
... when != n
// </smpl>
Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
---
arch/powerpc/kernel/btext.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/arch/powerpc/kernel/btext.c b/arch/powerpc/kernel/btext.c
index 41c011c..8d05ef2 100644
--- a/arch/powerpc/kernel/btext.c
+++ b/arch/powerpc/kernel/btext.c
@@ -257,8 +257,10 @@ int __init btext_find_display(int allow_nonstdout)
rc = btext_initialize(np);
printk("result: %d\n", rc);
}
- if (rc == 0)
+ if (rc == 0) {
+ of_node_put(np);
break;
+ }
}
return rc;
}
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 6/6] powerpc/cell: add missing of_node_put
2015-11-20 20:33 [PATCH 0/6] add missing of_node_put Julia Lawall
` (4 preceding siblings ...)
2015-11-20 20:33 ` [PATCH 5/6] powerpc/btext: " Julia Lawall
@ 2015-11-20 20:33 ` Julia Lawall
2021-11-25 9:35 ` (subset) [PATCH 0/6] " Michael Ellerman
6 siblings, 0 replies; 8+ messages in thread
From: Julia Lawall @ 2015-11-20 20:33 UTC (permalink / raw)
To: Arnd Bergmann
Cc: kernel-janitors, Benjamin Herrenschmidt, Paul Mackerras,
Michael Ellerman, linuxppc-dev, linux-kernel,
Russell King - ARM Linux, Thomas Petazzoni, Andrew Lunn,
Bjorn Helgaas, Jason Cooper
for_each_node_by_name performs an of_node_get on each iteration, so
a break out of the loop requires an of_node_put.
A simplified version of the semantic patch that fixes this problem is as
follows (http://coccinelle.lip6.fr):
// <smpl>
@@
expression e,e1;
local idexpression n;
@@
for_each_node_by_name(n, e1) {
... when != of_node_put(n)
when != e = n
(
return n;
|
+ of_node_put(n);
? return ...;
)
...
}
// </smpl>
Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
---
arch/powerpc/platforms/cell/iommu.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/powerpc/platforms/cell/iommu.c b/arch/powerpc/platforms/cell/iommu.c
index 14a582b..4edceff 100644
--- a/arch/powerpc/platforms/cell/iommu.c
+++ b/arch/powerpc/platforms/cell/iommu.c
@@ -1107,6 +1107,7 @@ static int __init cell_iommu_fixed_mapping_init(void)
if (hbase < dbase || (hend > (dbase + dsize))) {
pr_debug("iommu: hash window doesn't fit in"
"real DMA window\n");
+ of_node_put(np);
return -1;
}
}
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: (subset) [PATCH 0/6] add missing of_node_put
2015-11-20 20:33 [PATCH 0/6] add missing of_node_put Julia Lawall
` (5 preceding siblings ...)
2015-11-20 20:33 ` [PATCH 6/6] powerpc/cell: " Julia Lawall
@ 2021-11-25 9:35 ` Michael Ellerman
6 siblings, 0 replies; 8+ messages in thread
From: Michael Ellerman @ 2021-11-25 9:35 UTC (permalink / raw)
To: Julia Lawall, Benjamin Herrenschmidt
Cc: Michael Ellerman, kernel-janitors, linux-kernel, Paul Mackerras,
linuxppc-dev
On Fri, 20 Nov 2015 20:33:18 +0000, Julia Lawall wrote:
> The various for_each device_node iterators performs an of_node_get on each
> iteration, so a break out of the loop requires an of_node_put.
>
> The complete semantic patch that fixes this problem is
> (http://coccinelle.lip6.fr):
>
> // <smpl>
> @r@
> local idexpression n;
> expression e1,e2;
> iterator name for_each_node_by_name, for_each_node_by_type,
> for_each_compatible_node, for_each_matching_node,
> for_each_matching_node_and_match, for_each_child_of_node,
> for_each_available_child_of_node, for_each_node_with_property;
> iterator i;
> statement S;
> expression list [n1] es;
> @@
>
> [...]
Patch 5 applied to powerpc/next.
[5/6] powerpc/btext: add missing of_node_put
https://git.kernel.org/powerpc/c/a1d2b210ffa52d60acabbf7b6af3ef7e1e69cda0
cheers
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2021-11-25 9:49 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-20 20:33 [PATCH 0/6] add missing of_node_put Julia Lawall
2015-11-20 20:33 ` [PATCH 1/6] powerpc/6xx: " Julia Lawall
2015-11-20 20:33 ` [PATCH 2/6] powerpc/pseries: " Julia Lawall
2015-11-20 20:33 ` [PATCH 3/6] powerpc/powernv: " Julia Lawall
2015-11-20 20:33 ` [PATCH 4/6] powerpc/kexec: " Julia Lawall
2015-11-20 20:33 ` [PATCH 5/6] powerpc/btext: " Julia Lawall
2015-11-20 20:33 ` [PATCH 6/6] powerpc/cell: " Julia Lawall
2021-11-25 9:35 ` (subset) [PATCH 0/6] " Michael Ellerman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).