* [PATCH 0/5] add missing of_node_put
@ 2015-10-10 12:30 Julia Lawall
2015-10-10 12:30 ` [PATCH 3/5] ARM: shmobile: R-Mobile: " Julia Lawall
0 siblings, 1 reply; 8+ messages in thread
From: Julia Lawall @ 2015-10-10 12:30 UTC (permalink / raw)
To: linux-arm-kernel
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] 8+ messages in thread
* [PATCH 3/5] ARM: shmobile: R-Mobile: add missing of_node_put
2015-10-10 12:30 [PATCH 0/5] add missing of_node_put Julia Lawall
@ 2015-10-10 12:30 ` Julia Lawall
2015-10-12 0:16 ` Simon Horman
2015-10-12 7:18 ` Geert Uytterhoeven
0 siblings, 2 replies; 8+ messages in thread
From: Julia Lawall @ 2015-10-10 12:30 UTC (permalink / raw)
To: linux-arm-kernel
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 semantic patch that fixes this problem is as follows
(http://coccinelle.lip6.fr):
// <smpl>
@@
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>
Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
---
arch/arm/mach-shmobile/pm-rmobile.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/arch/arm/mach-shmobile/pm-rmobile.c b/arch/arm/mach-shmobile/pm-rmobile.c
index 89068c8..46d0a1d 100644
--- a/arch/arm/mach-shmobile/pm-rmobile.c
+++ b/arch/arm/mach-shmobile/pm-rmobile.c
@@ -313,8 +313,10 @@ static int __init rmobile_add_pm_domains(void __iomem *base,
}
pd = kzalloc(sizeof(*pd), GFP_KERNEL);
- if (!pd)
+ if (!pd) {
+ of_node_put(np);
return -ENOMEM;
+ }
pd->genpd.name = np->name;
pd->base = base;
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 3/5] ARM: shmobile: R-Mobile: add missing of_node_put
2015-10-10 12:30 ` [PATCH 3/5] ARM: shmobile: R-Mobile: " Julia Lawall
@ 2015-10-12 0:16 ` Simon Horman
2015-10-12 7:18 ` Geert Uytterhoeven
1 sibling, 0 replies; 8+ messages in thread
From: Simon Horman @ 2015-10-12 0:16 UTC (permalink / raw)
To: linux-arm-kernel
On Sat, Oct 10, 2015 at 02:30:52PM +0200, Julia Lawall wrote:
> 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 semantic patch that fixes this problem is as follows
> (http://coccinelle.lip6.fr):
>
> // <smpl>
> @@
> 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>
>
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Thanks, I have queued this up as a cleanup for v4.4.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 3/5] ARM: shmobile: R-Mobile: add missing of_node_put
2015-10-10 12:30 ` [PATCH 3/5] ARM: shmobile: R-Mobile: " Julia Lawall
2015-10-12 0:16 ` Simon Horman
@ 2015-10-12 7:18 ` Geert Uytterhoeven
2015-10-12 7:24 ` Julia Lawall
2015-10-12 7:29 ` Thomas Petazzoni
1 sibling, 2 replies; 8+ messages in thread
From: Geert Uytterhoeven @ 2015-10-12 7:18 UTC (permalink / raw)
To: linux-arm-kernel
Hi Julia,
On Sat, Oct 10, 2015 at 2:30 PM, Julia Lawall <Julia.Lawall@lip6.fr> wrote:
> --- a/arch/arm/mach-shmobile/pm-rmobile.c
> +++ b/arch/arm/mach-shmobile/pm-rmobile.c
> @@ -313,8 +313,10 @@ static int __init rmobile_add_pm_domains(void __iomem *base,
> }
>
> pd = kzalloc(sizeof(*pd), GFP_KERNEL);
> - if (!pd)
> + if (!pd) {
> + of_node_put(np);
> return -ENOMEM;
> + }
While technically this patch is correct, the system will be dead anyway if it
ever goes OOM at core_initcall() time.
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] 8+ messages in thread
* Re: [PATCH 3/5] ARM: shmobile: R-Mobile: add missing of_node_put
2015-10-12 7:18 ` Geert Uytterhoeven
@ 2015-10-12 7:24 ` Julia Lawall
2015-10-12 7:26 ` Geert Uytterhoeven
2015-10-12 7:29 ` Thomas Petazzoni
1 sibling, 1 reply; 8+ messages in thread
From: Julia Lawall @ 2015-10-12 7:24 UTC (permalink / raw)
To: linux-arm-kernel
On Mon, 12 Oct 2015, Geert Uytterhoeven wrote:
> Hi Julia,
>
> On Sat, Oct 10, 2015 at 2:30 PM, Julia Lawall <Julia.Lawall@lip6.fr> wrote:
> > --- a/arch/arm/mach-shmobile/pm-rmobile.c
> > +++ b/arch/arm/mach-shmobile/pm-rmobile.c
> > @@ -313,8 +313,10 @@ static int __init rmobile_add_pm_domains(void __iomem *base,
> > }
> >
> > pd = kzalloc(sizeof(*pd), GFP_KERNEL);
> > - if (!pd)
> > + if (!pd) {
> > + of_node_put(np);
> > return -ENOMEM;
> > + }
>
> While technically this patch is correct, the system will be dead anyway if it
> ever goes OOM at core_initcall() time.
Maybe it would be better for the code to be correct to serve as an example
(or to avoid serving as a bad example) for others?
julia
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 3/5] ARM: shmobile: R-Mobile: add missing of_node_put
2015-10-12 7:24 ` Julia Lawall
@ 2015-10-12 7:26 ` Geert Uytterhoeven
0 siblings, 0 replies; 8+ messages in thread
From: Geert Uytterhoeven @ 2015-10-12 7:26 UTC (permalink / raw)
To: linux-arm-kernel
Hi Julia,
On Mon, Oct 12, 2015 at 9:24 AM, Julia Lawall <julia.lawall@lip6.fr> wrote:
> On Mon, 12 Oct 2015, Geert Uytterhoeven wrote:
>> On Sat, Oct 10, 2015 at 2:30 PM, Julia Lawall <Julia.Lawall@lip6.fr> wrote:
>> > --- a/arch/arm/mach-shmobile/pm-rmobile.c
>> > +++ b/arch/arm/mach-shmobile/pm-rmobile.c
>> > @@ -313,8 +313,10 @@ static int __init rmobile_add_pm_domains(void __iomem *base,
>> > }
>> >
>> > pd = kzalloc(sizeof(*pd), GFP_KERNEL);
>> > - if (!pd)
>> > + if (!pd) {
>> > + of_node_put(np);
>> > return -ENOMEM;
>> > + }
>>
>> While technically this patch is correct, the system will be dead anyway if it
>> ever goes OOM at core_initcall() time.
>
> Maybe it would be better for the code to be correct to serve as an example
> (or to avoid serving as a bad example) for others?
Sure, as it's only a single call, that's fine for me.
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] 8+ messages in thread
* Re: [PATCH 3/5] ARM: shmobile: R-Mobile: add missing of_node_put
2015-10-12 7:18 ` Geert Uytterhoeven
2015-10-12 7:24 ` Julia Lawall
@ 2015-10-12 7:29 ` Thomas Petazzoni
2015-10-12 7:30 ` Geert Uytterhoeven
1 sibling, 1 reply; 8+ messages in thread
From: Thomas Petazzoni @ 2015-10-12 7:29 UTC (permalink / raw)
To: linux-arm-kernel
Dear Geert Uytterhoeven,
On Mon, 12 Oct 2015 09:18:52 +0200, Geert Uytterhoeven wrote:
> > pd = kzalloc(sizeof(*pd), GFP_KERNEL);
> > - if (!pd)
> > + if (!pd) {
> > + of_node_put(np);
> > return -ENOMEM;
> > + }
>
> While technically this patch is correct, the system will be dead anyway if it
> ever goes OOM at core_initcall() time.
Then BUG_ON(!pd); ?
Thomas
--
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 3/5] ARM: shmobile: R-Mobile: add missing of_node_put
2015-10-12 7:29 ` Thomas Petazzoni
@ 2015-10-12 7:30 ` Geert Uytterhoeven
0 siblings, 0 replies; 8+ messages in thread
From: Geert Uytterhoeven @ 2015-10-12 7:30 UTC (permalink / raw)
To: linux-arm-kernel
On Mon, Oct 12, 2015 at 9:29 AM, Thomas Petazzoni
<thomas.petazzoni@free-electrons.com> wrote:
> On Mon, 12 Oct 2015 09:18:52 +0200, Geert Uytterhoeven wrote:
>
>> > pd = kzalloc(sizeof(*pd), GFP_KERNEL);
>> > - if (!pd)
>> > + if (!pd) {
>> > + of_node_put(np);
>> > return -ENOMEM;
>> > + }
>>
>> While technically this patch is correct, the system will be dead anyway if it
>> ever goes OOM at core_initcall() time.
>
> Then BUG_ON(!pd); ?
kzalloc() will scream anyway.
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] 8+ messages in thread
end of thread, other threads:[~2015-10-12 7:30 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-10 12:30 [PATCH 0/5] add missing of_node_put Julia Lawall
2015-10-10 12:30 ` [PATCH 3/5] ARM: shmobile: R-Mobile: " Julia Lawall
2015-10-12 0:16 ` Simon Horman
2015-10-12 7:18 ` Geert Uytterhoeven
2015-10-12 7:24 ` Julia Lawall
2015-10-12 7:26 ` Geert Uytterhoeven
2015-10-12 7:29 ` Thomas Petazzoni
2015-10-12 7:30 ` Geert Uytterhoeven
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).