* [PATCH 0/3] delete unneeded of_node_put
@ 2015-10-12 20:43 Julia Lawall
2015-10-12 20:43 ` [PATCH 1/3] video: omapdss: " Julia Lawall
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Julia Lawall @ 2015-10-12 20:43 UTC (permalink / raw)
To: linux-arm-kernel
Device node iterators perform an of_node_put on each iteration, so putting
an of_node_put before going around to the next iteration results in a
double put.
The complete semantic patch that fixes this problem is as follows
(http://coccinelle.lip6.fr):
// <smpl>
@r exists@
expression e1,e2;
local idexpression n;
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;
position p1,p2;
statement S;
@@
(
(
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@p1(...) {
... when != of_node_get(n)
when any
of_node_put@p2(n);
... when any
}
)
@s exists@
local idexpression r.n;
statement S;
position r.p1,r.p2;
iterator i;
@@
of_node_put@p2(n);
... when any
i@p1(..., n, ...)
S
@depends on s@
local idexpression n;
position r.p2;
@@
- of_node_put@p2(n);
// </smpl>
---
arch/arm/mach-exynos/pm_domains.c | 8 +++-----
drivers/soc/qcom/smd.c | 4 +---
drivers/video/fbdev/omap2/dss/omapdss-boot-init.c | 4 +---
3 files changed, 5 insertions(+), 11 deletions(-)
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/3] video: omapdss: delete unneeded of_node_put
2015-10-12 20:43 [PATCH 0/3] delete unneeded of_node_put Julia Lawall
@ 2015-10-12 20:43 ` Julia Lawall
2015-11-24 11:37 ` Tomi Valkeinen
2015-10-12 20:43 ` [PATCH 2/3] soc: qcom: smd: " Julia Lawall
2015-10-12 20:43 ` [PATCH 3/3] ARM: EXYNOS: " Julia Lawall
2 siblings, 1 reply; 6+ messages in thread
From: Julia Lawall @ 2015-10-12 20:43 UTC (permalink / raw)
To: Tomi Valkeinen
Cc: kernel-janitors, Jean-Christophe Plagniol-Villard, linux-omap,
linux-fbdev, linux-kernel, Russell King - ARM Linux,
Thomas Petazzoni, Andrew Lunn, Bjorn Helgaas, Jason Cooper
Device node iterators perform an of_node_put on each iteration, so putting
an of_node_put before a continue results in a double put.
A simplified version of the semantic match that finds this problem is as
follows (http://coccinelle.lip6.fr):
// <smpl>
@@
expression root,e;
local idexpression child;
iterator i;
@@
i(..., child, ...) {
... when != of_node_get(child)
* of_node_put(child);
...
* continue;
}
// </smpl>
Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
---
drivers/video/fbdev/omap2/dss/omapdss-boot-init.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/video/fbdev/omap2/dss/omapdss-boot-init.c b/drivers/video/fbdev/omap2/dss/omapdss-boot-init.c
index 8b6f6d5..136d304 100644
--- a/drivers/video/fbdev/omap2/dss/omapdss-boot-init.c
+++ b/drivers/video/fbdev/omap2/dss/omapdss-boot-init.c
@@ -199,10 +199,8 @@ static int __init omapdss_boot_init(void)
omapdss_walk_device(dss, true);
for_each_available_child_of_node(dss, child) {
- if (!of_find_property(child, "compatible", NULL)) {
- of_node_put(child);
+ if (!of_find_property(child, "compatible", NULL))
continue;
- }
omapdss_walk_device(child, true);
}
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/3] soc: qcom: smd: delete unneeded of_node_put
2015-10-12 20:43 [PATCH 0/3] delete unneeded of_node_put Julia Lawall
2015-10-12 20:43 ` [PATCH 1/3] video: omapdss: " Julia Lawall
@ 2015-10-12 20:43 ` Julia Lawall
2015-10-12 20:43 ` [PATCH 3/3] ARM: EXYNOS: " Julia Lawall
2 siblings, 0 replies; 6+ messages in thread
From: Julia Lawall @ 2015-10-12 20:43 UTC (permalink / raw)
To: Kumar Gala
Cc: kernel-janitors, Andy Gross, David Brown, linux-arm-msm,
linux-soc, linux-kernel, Russell King - ARM Linux,
Thomas Petazzoni, Andrew Lunn, Bjorn Helgaas, Jason Cooper
Device node iterators perform an of_node_put on each iteration, so putting
an of_node_put before a continue results in a double put.
A simplified version of the semantic match that finds this problem is as
follows (http://coccinelle.lip6.fr):
// <smpl>
@@
expression root,e;
local idexpression child;
iterator i;
@@
i(..., child, ...) {
... when != of_node_get(child)
* of_node_put(child);
...
* continue;
}
// </smpl>
Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
---
drivers/soc/qcom/smd.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/soc/qcom/smd.c b/drivers/soc/qcom/smd.c
index 6da0463..8c7a489 100644
--- a/drivers/soc/qcom/smd.c
+++ b/drivers/soc/qcom/smd.c
@@ -916,10 +916,8 @@ static struct device_node *qcom_smd_match_channel(struct device_node *edge_node,
for_each_available_child_of_node(edge_node, child) {
key = "qcom,smd-channels";
ret = of_property_read_string(child, key, &name);
- if (ret) {
- of_node_put(child);
+ if (ret)
continue;
- }
if (strcmp(name, channel) = 0)
return child;
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 3/3] ARM: EXYNOS: delete unneeded of_node_put
2015-10-12 20:43 [PATCH 0/3] delete unneeded of_node_put Julia Lawall
2015-10-12 20:43 ` [PATCH 1/3] video: omapdss: " Julia Lawall
2015-10-12 20:43 ` [PATCH 2/3] soc: qcom: smd: " Julia Lawall
@ 2015-10-12 20:43 ` Julia Lawall
2015-10-12 22:40 ` Javier Martinez Canillas
2 siblings, 1 reply; 6+ messages in thread
From: Julia Lawall @ 2015-10-12 20:43 UTC (permalink / raw)
To: linux-arm-kernel
Device node iterators perform an of_node_put on each iteration, so putting
an of_node_put before going around to the next iteration results in a
double put.
Problem found using Coccinelle.
Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
---
arch/arm/mach-exynos/pm_domains.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/arch/arm/mach-exynos/pm_domains.c b/arch/arm/mach-exynos/pm_domains.c
index 4a87e86..7c21760 100644
--- a/arch/arm/mach-exynos/pm_domains.c
+++ b/arch/arm/mach-exynos/pm_domains.c
@@ -200,15 +200,15 @@ no_clk:
args.args_count = 0;
child_domain = of_genpd_get_from_provider(&args);
if (IS_ERR(child_domain))
- goto next_pd;
+ continue;
if (of_parse_phandle_with_args(np, "power-domains",
"#power-domain-cells", 0, &args) != 0)
- goto next_pd;
+ continue;
parent_domain = of_genpd_get_from_provider(&args);
if (IS_ERR(parent_domain))
- goto next_pd;
+ continue;
if (pm_genpd_add_subdomain(parent_domain, child_domain))
pr_warn("%s failed to add subdomain: %s\n",
@@ -216,8 +216,6 @@ no_clk:
else
pr_info("%s has as child subdomain: %s.\n",
parent_domain->name, child_domain->name);
-next_pd:
- of_node_put(np);
}
return 0;
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 3/3] ARM: EXYNOS: delete unneeded of_node_put
2015-10-12 20:43 ` [PATCH 3/3] ARM: EXYNOS: " Julia Lawall
@ 2015-10-12 22:40 ` Javier Martinez Canillas
0 siblings, 0 replies; 6+ messages in thread
From: Javier Martinez Canillas @ 2015-10-12 22:40 UTC (permalink / raw)
To: linux-arm-kernel
Hello Julia,
On 10/12/2015 10:43 PM, Julia Lawall wrote:
> Device node iterators perform an of_node_put on each iteration, so putting
> an of_node_put before going around to the next iteration results in a
> double put.
>
> Problem found using Coccinelle.
>
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
>
Krzysztof sent the same patch yesterday and was already applied:
https://lkml.org/lkml/2015/10/12/688
Best regards,
--
Javier Martinez Canillas
Open Source Group
Samsung Research America
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/3] video: omapdss: delete unneeded of_node_put
2015-10-12 20:43 ` [PATCH 1/3] video: omapdss: " Julia Lawall
@ 2015-11-24 11:37 ` Tomi Valkeinen
0 siblings, 0 replies; 6+ messages in thread
From: Tomi Valkeinen @ 2015-11-24 11:37 UTC (permalink / raw)
To: Julia Lawall
Cc: kernel-janitors, Jean-Christophe Plagniol-Villard, linux-omap,
linux-fbdev, linux-kernel, Russell King - ARM Linux,
Thomas Petazzoni, Andrew Lunn, Bjorn Helgaas, Jason Cooper
[-- Attachment #1: Type: text/plain, Size: 759 bytes --]
On 12/10/15 23:43, Julia Lawall wrote:
> Device node iterators perform an of_node_put on each iteration, so putting
> an of_node_put before a continue results in a double put.
>
> A simplified version of the semantic match that finds this problem is as
> follows (http://coccinelle.lip6.fr):
>
> // <smpl>
> @@
> expression root,e;
> local idexpression child;
> iterator i;
> @@
>
> i(..., child, ...) {
> ... when != of_node_get(child)
> * of_node_put(child);
> ...
> * continue;
> }
> // </smpl>
>
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
>
> ---
> drivers/video/fbdev/omap2/dss/omapdss-boot-init.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
Thanks, queued for 4.5.
Tomi
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-11-24 11:37 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-12 20:43 [PATCH 0/3] delete unneeded of_node_put Julia Lawall
2015-10-12 20:43 ` [PATCH 1/3] video: omapdss: " Julia Lawall
2015-11-24 11:37 ` Tomi Valkeinen
2015-10-12 20:43 ` [PATCH 2/3] soc: qcom: smd: " Julia Lawall
2015-10-12 20:43 ` [PATCH 3/3] ARM: EXYNOS: " Julia Lawall
2015-10-12 22:40 ` Javier Martinez Canillas
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).