* [PATCH 0/5] add missing of_node_put
@ 2015-12-21 16:39 Julia Lawall
2015-12-21 16:39 ` [PATCH 1/5] pinctrl-tegra: " Julia Lawall
` (4 more replies)
0 siblings, 5 replies; 17+ messages in thread
From: Julia Lawall @ 2015-12-21 16:39 UTC (permalink / raw)
To: linux-rockchip
Cc: kernel-janitors, linux-arm-kernel, linux-kernel, linux-gpio,
Linus Walleij, linux-sh, linux-mediatek
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>
---
drivers/pinctrl/mediatek/pinctrl-mtk-common.c | 1 +
drivers/pinctrl/pinctrl-rockchip.c | 5 ++++-
drivers/pinctrl/pinctrl-tegra-xusb.c | 4 +++-
drivers/pinctrl/pinctrl-tegra.c | 1 +
drivers/pinctrl/sh-pfc/pinctrl.c | 4 +++-
drivers/pinctrl/sirf/pinctrl-sirf.c | 8 ++++++--
6 files changed, 18 insertions(+), 5 deletions(-)
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH 1/5] pinctrl-tegra: add missing of_node_put
2015-12-21 16:39 [PATCH 0/5] add missing of_node_put Julia Lawall
@ 2015-12-21 16:39 ` Julia Lawall
2015-12-22 12:44 ` Linus Walleij
2015-12-21 16:39 ` [PATCH 2/5] pinctrl: sirf: " Julia Lawall
` (3 subsequent siblings)
4 siblings, 1 reply; 17+ messages in thread
From: Julia Lawall @ 2015-12-21 16:39 UTC (permalink / raw)
To: Linus Walleij
Cc: kernel-janitors, Stephen Warren, Thierry Reding,
Alexandre Courbot, linux-gpio, linux-tegra, linux-kernel
for_each_child_of_node performs an of_node_get on each iteration, so a
return from 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,e1;
@@
for_each_child_of_node(e1,n) {
...
(
of_node_put(n);
|
e = n
|
return n;
|
+ of_node_put(n);
? return ...;
)
...
}
// </smpl>
Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
---
drivers/pinctrl/pinctrl-tegra-xusb.c | 4 +++-
drivers/pinctrl/pinctrl-tegra.c | 1 +
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/pinctrl/pinctrl-tegra-xusb.c b/drivers/pinctrl/pinctrl-tegra-xusb.c
index 84a43e6..bd3aa5a 100644
--- a/drivers/pinctrl/pinctrl-tegra-xusb.c
+++ b/drivers/pinctrl/pinctrl-tegra-xusb.c
@@ -253,8 +253,10 @@ static int tegra_xusb_padctl_dt_node_to_map(struct pinctrl_dev *pinctrl,
err = tegra_xusb_padctl_parse_subnode(padctl, np, maps,
&reserved_maps,
num_maps);
- if (err < 0)
+ if (err < 0) {
+ of_node_put(np);
return err;
+ }
}
return 0;
diff --git a/drivers/pinctrl/pinctrl-tegra.c b/drivers/pinctrl/pinctrl-tegra.c
index 0fd7fd2..9da4da2 100644
--- a/drivers/pinctrl/pinctrl-tegra.c
+++ b/drivers/pinctrl/pinctrl-tegra.c
@@ -217,6 +217,7 @@ static int tegra_pinctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
if (ret < 0) {
pinctrl_utils_dt_free_map(pctldev, *map,
*num_maps);
+ of_node_put(np);
return ret;
}
}
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH 2/5] pinctrl: sirf: add missing of_node_put
2015-12-21 16:39 [PATCH 0/5] add missing of_node_put Julia Lawall
2015-12-21 16:39 ` [PATCH 1/5] pinctrl-tegra: " Julia Lawall
@ 2015-12-21 16:39 ` Julia Lawall
2015-12-22 12:45 ` Linus Walleij
2015-12-21 16:39 ` [PATCH 3/5] pinctrl: sh-pfc: " Julia Lawall
` (2 subsequent siblings)
4 siblings, 1 reply; 17+ messages in thread
From: Julia Lawall @ 2015-12-21 16:39 UTC (permalink / raw)
To: Linus Walleij
Cc: kernel-janitors, Barry Song, linux-gpio, linux-arm-kernel, linux-kernel
for_each_child_of_node performs an of_node_get on each iteration, so a
return from 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,e1;
@@
for_each_child_of_node(e1,n) {
...
(
of_node_put(n);
|
e = n
|
return n;
|
+ of_node_put(n);
? return ...;
)
...
}
// </smpl>
Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
---
drivers/pinctrl/sirf/pinctrl-sirf.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/pinctrl/sirf/pinctrl-sirf.c b/drivers/pinctrl/sirf/pinctrl-sirf.c
index ae97bdc..18fe46d 100644
--- a/drivers/pinctrl/sirf/pinctrl-sirf.c
+++ b/drivers/pinctrl/sirf/pinctrl-sirf.c
@@ -85,12 +85,16 @@ static int sirfsoc_dt_node_to_map(struct pinctrl_dev *pctldev,
/* calculate number of maps required */
for_each_child_of_node(np_config, np) {
ret = of_property_read_string(np, "sirf,function", &function);
- if (ret < 0)
+ if (ret < 0) {
+ of_node_put(np);
return ret;
+ }
ret = of_property_count_strings(np, "sirf,pins");
- if (ret < 0)
+ if (ret < 0) {
+ of_node_put(np);
return ret;
+ }
count += ret;
}
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH 3/5] pinctrl: sh-pfc: add missing of_node_put
2015-12-21 16:39 [PATCH 0/5] add missing of_node_put Julia Lawall
2015-12-21 16:39 ` [PATCH 1/5] pinctrl-tegra: " Julia Lawall
2015-12-21 16:39 ` [PATCH 2/5] pinctrl: sirf: " Julia Lawall
@ 2015-12-21 16:39 ` Julia Lawall
2015-12-21 20:46 ` Laurent Pinchart
2015-12-22 12:47 ` Linus Walleij
2015-12-21 16:39 ` [PATCH 4/5] pinctrl: rockchip: " Julia Lawall
2015-12-21 16:39 ` [PATCH 5/5] pinctrl: mediatek: " Julia Lawall
4 siblings, 2 replies; 17+ messages in thread
From: Julia Lawall @ 2015-12-21 16:39 UTC (permalink / raw)
To: Laurent Pinchart
Cc: kernel-janitors, Linus Walleij, linux-sh, linux-gpio, linux-kernel
for_each_child_of_node performs an of_node_get on each iteration, so a
goto 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,e1;
identifier l;
@@
for_each_child_of_node(e1,n) {
...
(
of_node_put(n);
|
e = n
|
return n;
|
+ of_node_put(n);
? goto l;
)
...
}
l: ... when != n
// </smpl>
Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
---
drivers/pinctrl/sh-pfc/pinctrl.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/pinctrl/sh-pfc/pinctrl.c b/drivers/pinctrl/sh-pfc/pinctrl.c
index 863c3e3..87b0a59 100644
--- a/drivers/pinctrl/sh-pfc/pinctrl.c
+++ b/drivers/pinctrl/sh-pfc/pinctrl.c
@@ -273,8 +273,10 @@ static int sh_pfc_dt_node_to_map(struct pinctrl_dev *pctldev,
for_each_child_of_node(np, child) {
ret = sh_pfc_dt_subnode_to_map(pctldev, child, map, num_maps,
&index);
- if (ret < 0)
+ if (ret < 0) {
+ of_node_put(child);
goto done;
+ }
}
/* If no mapping has been found in child nodes try the config node. */
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH 4/5] pinctrl: rockchip: add missing of_node_put
2015-12-21 16:39 [PATCH 0/5] add missing of_node_put Julia Lawall
` (2 preceding siblings ...)
2015-12-21 16:39 ` [PATCH 3/5] pinctrl: sh-pfc: " Julia Lawall
@ 2015-12-21 16:39 ` Julia Lawall
2015-12-21 21:20 ` Heiko Stübner
2015-12-22 12:48 ` Linus Walleij
2015-12-21 16:39 ` [PATCH 5/5] pinctrl: mediatek: " Julia Lawall
4 siblings, 2 replies; 17+ messages in thread
From: Julia Lawall @ 2015-12-21 16:39 UTC (permalink / raw)
To: Linus Walleij
Cc: kernel-janitors, Heiko Stuebner, linux-gpio, linux-arm-kernel,
linux-rockchip, linux-kernel
for_each_child_of_node performs an of_node_get on each iteration, so a
return from 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,e1;
@@
for_each_child_of_node(e1,n) {
...
(
of_node_put(n);
|
e = n
|
return n;
|
+ of_node_put(n);
? return ...;
)
...
}
// </smpl>
Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
---
drivers/pinctrl/pinctrl-rockchip.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c
index 2b88a40..d0305a2 100644
--- a/drivers/pinctrl/pinctrl-rockchip.c
+++ b/drivers/pinctrl/pinctrl-rockchip.c
@@ -1258,8 +1258,10 @@ static int rockchip_pinctrl_parse_functions(struct device_node *np,
func->groups[i] = child->name;
grp = &info->groups[grp_index++];
ret = rockchip_pinctrl_parse_groups(child, grp, info, i++);
- if (ret)
+ if (ret) {
+ of_node_put(child);
return ret;
+ }
}
return 0;
@@ -1304,6 +1306,7 @@ static int rockchip_pinctrl_parse_dt(struct platform_device *pdev,
ret = rockchip_pinctrl_parse_functions(child, info, i++);
if (ret) {
dev_err(&pdev->dev, "failed to parse function\n");
+ of_node_put(child);
return ret;
}
}
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH 5/5] pinctrl: mediatek: add missing of_node_put
2015-12-21 16:39 [PATCH 0/5] add missing of_node_put Julia Lawall
` (3 preceding siblings ...)
2015-12-21 16:39 ` [PATCH 4/5] pinctrl: rockchip: " Julia Lawall
@ 2015-12-21 16:39 ` Julia Lawall
2015-12-22 12:49 ` Linus Walleij
4 siblings, 1 reply; 17+ messages in thread
From: Julia Lawall @ 2015-12-21 16:39 UTC (permalink / raw)
To: Linus Walleij
Cc: kernel-janitors, Matthias Brugger, linux-gpio, linux-arm-kernel,
linux-mediatek, linux-kernel
for_each_child_of_node performs an of_node_get on each iteration, so a
return from 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,e1;
@@
for_each_child_of_node(e1,n) {
...
(
of_node_put(n);
|
e = n
|
return n;
|
+ of_node_put(n);
? return ...;
)
...
}
// </smpl>
Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
---
drivers/pinctrl/mediatek/pinctrl-mtk-common.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
index 45f3562..ee2287b 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
@@ -598,6 +598,7 @@ static int mtk_pctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
&reserved_maps, num_maps);
if (ret < 0) {
pinctrl_utils_dt_free_map(pctldev, *map, *num_maps);
+ of_node_put(np);
return ret;
}
}
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH 3/5] pinctrl: sh-pfc: add missing of_node_put
2015-12-21 16:39 ` [PATCH 3/5] pinctrl: sh-pfc: " Julia Lawall
@ 2015-12-21 20:46 ` Laurent Pinchart
2015-12-22 12:47 ` Linus Walleij
1 sibling, 0 replies; 17+ messages in thread
From: Laurent Pinchart @ 2015-12-21 20:46 UTC (permalink / raw)
To: Julia Lawall
Cc: kernel-janitors, Linus Walleij, linux-sh, linux-gpio, linux-kernel
Hi Julia,
Thank you for the patch.
On Monday 21 December 2015 17:39:46 Julia Lawall wrote:
> for_each_child_of_node performs an of_node_get on each iteration, so a
> goto 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,e1;
> identifier l;
> @@
>
> for_each_child_of_node(e1,n) {
> ...
> (
> of_node_put(n);
>
> e = n
>
> return n;
>
> + of_node_put(n);
> ? goto l;
> )
> ...
> }
> l: ... when != n
> // </smpl>
>
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
> drivers/pinctrl/sh-pfc/pinctrl.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/pinctrl/sh-pfc/pinctrl.c
> b/drivers/pinctrl/sh-pfc/pinctrl.c index 863c3e3..87b0a59 100644
> --- a/drivers/pinctrl/sh-pfc/pinctrl.c
> +++ b/drivers/pinctrl/sh-pfc/pinctrl.c
> @@ -273,8 +273,10 @@ static int sh_pfc_dt_node_to_map(struct pinctrl_dev
> *pctldev, for_each_child_of_node(np, child) {
> ret = sh_pfc_dt_subnode_to_map(pctldev, child, map, num_maps,
> &index);
> - if (ret < 0)
> + if (ret < 0) {
> + of_node_put(child);
> goto done;
> + }
> }
>
> /* If no mapping has been found in child nodes try the config node. */
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 4/5] pinctrl: rockchip: add missing of_node_put
2015-12-21 16:39 ` [PATCH 4/5] pinctrl: rockchip: " Julia Lawall
@ 2015-12-21 21:20 ` Heiko Stübner
2015-12-22 12:48 ` Linus Walleij
1 sibling, 0 replies; 17+ messages in thread
From: Heiko Stübner @ 2015-12-21 21:20 UTC (permalink / raw)
To: Julia Lawall
Cc: Linus Walleij, kernel-janitors, linux-gpio, linux-arm-kernel,
linux-rockchip, linux-kernel
Hi Julia,
Am Montag, 21. Dezember 2015, 17:39:47 schrieb Julia Lawall:
> for_each_child_of_node performs an of_node_get on each iteration, so a
> return from 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,e1;
> @@
>
> for_each_child_of_node(e1,n) {
> ...
> (
> of_node_put(n);
>
> e = n
>
> return n;
>
> + of_node_put(n);
> ? return ...;
> )
> ...
> }
> // </smpl>
>
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
thanks for catching this :-)
I still remember how we talked about that same issue in the phy driver and the
things for_each_child_of_node does when running, so
Reviewed-by: Heiko Stuebner <heiko@sntech.de>
Thanks
Heiko
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 1/5] pinctrl-tegra: add missing of_node_put
2015-12-21 16:39 ` [PATCH 1/5] pinctrl-tegra: " Julia Lawall
@ 2015-12-22 12:44 ` Linus Walleij
0 siblings, 0 replies; 17+ messages in thread
From: Linus Walleij @ 2015-12-22 12:44 UTC (permalink / raw)
To: Julia Lawall
Cc: kernel-janitors, Stephen Warren, Thierry Reding,
Alexandre Courbot, linux-gpio, linux-tegra, linux-kernel
On Mon, Dec 21, 2015 at 5:39 PM, Julia Lawall <Julia.Lawall@lip6.fr> wrote:
> for_each_child_of_node performs an of_node_get on each iteration, so a
> return from 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):
Patch applied.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 2/5] pinctrl: sirf: add missing of_node_put
2015-12-21 16:39 ` [PATCH 2/5] pinctrl: sirf: " Julia Lawall
@ 2015-12-22 12:45 ` Linus Walleij
0 siblings, 0 replies; 17+ messages in thread
From: Linus Walleij @ 2015-12-22 12:45 UTC (permalink / raw)
To: Julia Lawall
Cc: kernel-janitors, Barry Song, linux-gpio, linux-arm-kernel, linux-kernel
On Mon, Dec 21, 2015 at 5:39 PM, Julia Lawall <Julia.Lawall@lip6.fr> wrote:
> for_each_child_of_node performs an of_node_get on each iteration, so a
> return from 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):
Patch applied.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 3/5] pinctrl: sh-pfc: add missing of_node_put
2015-12-21 16:39 ` [PATCH 3/5] pinctrl: sh-pfc: " Julia Lawall
2015-12-21 20:46 ` Laurent Pinchart
@ 2015-12-22 12:47 ` Linus Walleij
2015-12-22 13:23 ` Geert Uytterhoeven
1 sibling, 1 reply; 17+ messages in thread
From: Linus Walleij @ 2015-12-22 12:47 UTC (permalink / raw)
To: Julia Lawall, Geert Uytterhoeven
Cc: Laurent Pinchart, kernel-janitors, linux-sh, linux-gpio, linux-kernel
On Mon, Dec 21, 2015 at 5:39 PM, Julia Lawall <Julia.Lawall@lip6.fr> wrote:
> for_each_child_of_node performs an of_node_get on each iteration, so a
> goto 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):
Patch applied with Laurent's ACK.
Geert: since I don't think you're gonna send me more pull
requests before the merge window I went ahead and applied
this directly, OK?
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 4/5] pinctrl: rockchip: add missing of_node_put
2015-12-21 16:39 ` [PATCH 4/5] pinctrl: rockchip: " Julia Lawall
2015-12-21 21:20 ` Heiko Stübner
@ 2015-12-22 12:48 ` Linus Walleij
1 sibling, 0 replies; 17+ messages in thread
From: Linus Walleij @ 2015-12-22 12:48 UTC (permalink / raw)
To: Julia Lawall
Cc: kernel-janitors, Heiko Stuebner, linux-gpio, linux-arm-kernel,
open list:ARM/Rockchip SoC...,
linux-kernel
On Mon, Dec 21, 2015 at 5:39 PM, Julia Lawall <Julia.Lawall@lip6.fr> wrote:
> for_each_child_of_node performs an of_node_get on each iteration, so a
> return from 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):
Patch applied with Heiko's review tag.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 5/5] pinctrl: mediatek: add missing of_node_put
2015-12-21 16:39 ` [PATCH 5/5] pinctrl: mediatek: " Julia Lawall
@ 2015-12-22 12:49 ` Linus Walleij
0 siblings, 0 replies; 17+ messages in thread
From: Linus Walleij @ 2015-12-22 12:49 UTC (permalink / raw)
To: Julia Lawall
Cc: kernel-janitors, Matthias Brugger, linux-gpio, linux-arm-kernel,
moderated list:ARM/Mediatek SoC support, linux-kernel
On Mon, Dec 21, 2015 at 5:39 PM, Julia Lawall <Julia.Lawall@lip6.fr> wrote:
> for_each_child_of_node performs an of_node_get on each iteration, so a
> return from 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):
Patch applied.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 3/5] pinctrl: sh-pfc: add missing of_node_put
2015-12-22 12:47 ` Linus Walleij
@ 2015-12-22 13:23 ` Geert Uytterhoeven
0 siblings, 0 replies; 17+ messages in thread
From: Geert Uytterhoeven @ 2015-12-22 13:23 UTC (permalink / raw)
To: Linus Walleij
Cc: Julia Lawall, Geert Uytterhoeven, Laurent Pinchart,
kernel-janitors, linux-sh, linux-gpio, linux-kernel
Hi Linus,
On Tue, Dec 22, 2015 at 1:47 PM, Linus Walleij <linus.walleij@linaro.org> wrote:
> On Mon, Dec 21, 2015 at 5:39 PM, Julia Lawall <Julia.Lawall@lip6.fr> wrote:
>> for_each_child_of_node performs an of_node_get on each iteration, so a
>> goto 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):
>
> Patch applied with Laurent's ACK.
>
> Geert: since I don't think you're gonna send me more pull
> requests before the merge window I went ahead and applied
> this directly, OK?
You're reading my mind ;-)
Thanks!
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH 0/5] add missing of_node_put
@ 2018-05-23 19:07 Julia Lawall
0 siblings, 0 replies; 17+ messages in thread
From: Julia Lawall @ 2018-05-23 19:07 UTC (permalink / raw)
To: linux-pci
Cc: kernel-janitors, linuxppc-dev, linux-kernel, linux-arm-kernel,
linux-gpio, dri-devel, linux-rockchip
The device node iterators perform an of_node_get on each iteration, so a
jump out of the loop requires an of_node_put.
---
drivers/gpu/drm/rockchip/rockchip_lvds.c | 4 +++-
drivers/pci/hotplug/pnv_php.c | 8 ++++++--
drivers/phy/hisilicon/phy-hisi-inno-usb2.c | 9 +++++++--
drivers/pinctrl/pinctrl-at91-pio4.c | 4 +++-
drivers/soc/ti/knav_dma.c | 1 +
5 files changed, 20 insertions(+), 6 deletions(-)
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH 0/5] add missing of_node_put
@ 2015-10-21 20:41 Julia Lawall
0 siblings, 0 replies; 17+ messages in thread
From: Julia Lawall @ 2015-10-21 20:41 UTC (permalink / raw)
To: linux-arm-kernel
Cc: kernel-janitors, linux-kernel, linux-clk, Stephen Boyd,
Michael Turquette, Russell King - ARM Linux, Thomas Petazzoni,
Andrew Lunn, Bjorn Helgaas, Jason Cooper
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>
---
drivers/clk/clk-scpi.c | 1 +
drivers/clk/clk-si5351.c | 17 ++++++++++-------
drivers/clk/clk.c | 4 ++++
drivers/clk/imx/clk-imx27.c | 4 +++-
drivers/clk/imx/clk-imx31.c | 4 +++-
5 files changed, 21 insertions(+), 9 deletions(-)
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH 0/5] add missing of_node_put
@ 2015-10-10 12:30 Julia Lawall
0 siblings, 0 replies; 17+ messages in thread
From: Julia Lawall @ 2015-10-10 12:30 UTC (permalink / raw)
To: linux-pm
Cc: kernel-janitors, linux-kernel, linux-fbdev, linux-sh,
linux-arm-kernel, Russell King - ARM Linux, Thomas Petazzoni,
Andrew Lunn, Bjorn Helgaas, Jason Cooper
for_each_child_of_node 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>
@@
expression root,e;
local idexpression child;
iterator name for_each_child_of_node;
@@
for_each_child_of_node(root, child) {
... when != of_node_put(child)
when != e = child
+ of_node_put(child);
? break;
...
}
... when != child
@@
expression root,e;
local idexpression child;
@@
for_each_child_of_node(root, child) {
... when != of_node_put(child)
when != e = child
(
return child;
|
+ of_node_put(child);
? return ...;
)
...
}
// </smpl>
---
arch/arm/kernel/devtree.c | 1 +
arch/arm/mach-shmobile/pm-rmobile.c | 4 +++-
drivers/power/charger-manager.c | 4 +++-
drivers/regulator/of_regulator.c | 1 +
drivers/video/backlight/88pm860x_bl.c | 1 +
5 files changed, 9 insertions(+), 2 deletions(-)
^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2018-05-23 19:39 UTC | newest]
Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-21 16:39 [PATCH 0/5] add missing of_node_put Julia Lawall
2015-12-21 16:39 ` [PATCH 1/5] pinctrl-tegra: " Julia Lawall
2015-12-22 12:44 ` Linus Walleij
2015-12-21 16:39 ` [PATCH 2/5] pinctrl: sirf: " Julia Lawall
2015-12-22 12:45 ` Linus Walleij
2015-12-21 16:39 ` [PATCH 3/5] pinctrl: sh-pfc: " Julia Lawall
2015-12-21 20:46 ` Laurent Pinchart
2015-12-22 12:47 ` Linus Walleij
2015-12-22 13:23 ` Geert Uytterhoeven
2015-12-21 16:39 ` [PATCH 4/5] pinctrl: rockchip: " Julia Lawall
2015-12-21 21:20 ` Heiko Stübner
2015-12-22 12:48 ` Linus Walleij
2015-12-21 16:39 ` [PATCH 5/5] pinctrl: mediatek: " Julia Lawall
2015-12-22 12:49 ` Linus Walleij
-- strict thread matches above, loose matches on Subject: below --
2018-05-23 19:07 [PATCH 0/5] " Julia Lawall
2015-10-21 20:41 Julia Lawall
2015-10-10 12:30 Julia Lawall
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).