[PATCH 1/3] powerpc/pmac: Fix DT refcount imbalance in pmac_pic_probe_oldstyle

Subsystems: linux for power macintosh, linux for powerpc (32-bit and 64-bit), the rest

STALE4201d

4 messages, 3 authors, 2015-02-03 · open the first message on its own page

[PATCH 1/3] powerpc/pmac: Fix DT refcount imbalance in pmac_pic_probe_oldstyle

From: Geert Uytterhoeven <geert+renesas@glider.be>
Date: 2015-01-14 13:52:03

of_find_node_by_name() calls of_node_put() on its "from" parameter,
which must not be done on "master", as it's still in use, and will be
released manually later.  This may cause a zero kref refcount.
Use of_get_child_by_name() instead to fix this.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: linuxppc-dev@lists.ozlabs.org
---
Compile-tested only
---
 arch/powerpc/platforms/powermac/pic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/powerpc/platforms/powermac/pic.c b/arch/powerpc/platforms/powermac/pic.c
index 4c24bf60d39d2834..90ada1209c118902 100644
--- a/arch/powerpc/platforms/powermac/pic.c
+++ b/arch/powerpc/platforms/powermac/pic.c
@@ -321,7 +321,7 @@ static void __init pmac_pic_probe_oldstyle(void)
 		max_irqs = max_real_irqs = 64;
 
 		/* We might have a second cascaded heathrow */
-		slave = of_find_node_by_name(master, "mac-io");
+		slave = of_get_child_by_name(master, "mac-io");
 
 		/* Check ordering of master & slave */
 		if (of_device_is_compatible(master, "gatwick")) {
-- 
1.9.1

Re: [1/3] powerpc/pmac: Fix DT refcount imbalance in pmac_pic_probe_oldstyle

From: Michael Ellerman <mpe@ellerman.id.au>
Date: 2015-01-30 04:09:09

On Wed, 2015-14-01 at 13:51:57 UTC, Geert Uytterhoeven wrote:
of_find_node_by_name() calls of_node_put() on its "from" parameter,
which must not be done on "master", as it's still in use, and will be
released manually later.  This may cause a zero kref refcount.
Use of_get_child_by_name() instead to fix this.
But of_find_node_by_name() searches *all* nodes, not just the children of the
parameter.

So this is a logic change AFAICS, and I have no idea what machines we'd need to
test on to check it.

So I think an of_node_get(master) would be safer and also fix the refcounting.

cheers

Re: [1/3] powerpc/pmac: Fix DT refcount imbalance in pmac_pic_probe_oldstyle

From: Geert Uytterhoeven <geert@linux-m68k.org>
Date: 2015-01-30 09:00:27

Hi Michael,

On Fri, Jan 30, 2015 at 5:09 AM, Michael Ellerman [off-list ref] wrote:
On Wed, 2015-14-01 at 13:51:57 UTC, Geert Uytterhoeven wrote:
quoted
of_find_node_by_name() calls of_node_put() on its "from" parameter,
which must not be done on "master", as it's still in use, and will be
released manually later.  This may cause a zero kref refcount.
Use of_get_child_by_name() instead to fix this.
But of_find_node_by_name() searches *all* nodes, not just the children of the
parameter.
That's correct. However, I guess the second mac-io will just be a direct child.
So this is a logic change AFAICS, and I have no idea what machines we'd need to
test on to check it.
Originally it comes from arch/ppc/platforms/pmac_pic.c, added in 2002 in
full-history-linux commit 5ea3254844ae344a
("Import arch/ppc and include/asm-ppc changes from linuxppc_2_5 tree").

I've also checked my linuxppc mail archives from 1997-2002, but couldn't find
the actual patch and a description.

So I don't know on which machines it's needed.
So I think an of_node_get(master) would be safer and also fix the refcounting.
If no one can confirm the above, that may indeed be the best solution.

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

Re: [1/3] powerpc/pmac: Fix DT refcount imbalance in pmac_pic_probe_oldstyle

From: Michael Ellerman <mpe@ellerman.id.au>
Date: 2015-02-03 01:12:37

On Fri, 2015-01-30 at 10:00 +0100, Geert Uytterhoeven wrote:
Hi Michael,

On Fri, Jan 30, 2015 at 5:09 AM, Michael Ellerman [off-list ref] wrote:
quoted
On Wed, 2015-14-01 at 13:51:57 UTC, Geert Uytterhoeven wrote:
quoted
of_find_node_by_name() calls of_node_put() on its "from" parameter,
which must not be done on "master", as it's still in use, and will be
released manually later.  This may cause a zero kref refcount.
Use of_get_child_by_name() instead to fix this.
But of_find_node_by_name() searches *all* nodes, not just the children of the
parameter.
That's correct. However, I guess the second mac-io will just be a direct child.
Yeah OK, I don't have a system or an example device tree to check.
quoted
So this is a logic change AFAICS, and I have no idea what machines we'd need to
test on to check it.
Originally it comes from arch/ppc/platforms/pmac_pic.c, added in 2002 in
full-history-linux commit 5ea3254844ae344a
("Import arch/ppc and include/asm-ppc changes from linuxppc_2_5 tree").

I've also checked my linuxppc mail archives from 1997-2002, but couldn't find
the actual patch and a description.

So I don't know on which machines it's needed.
Yep. Ben or Paul might know, but even then their memory may not be perfect :)
 
quoted
So I think an of_node_get(master) would be safer and also fix the refcounting.
If no one can confirm the above, that may indeed be the best solution.
I think so. Given how few of these machines are around it's easy to break them
with an inadvertent change like this, so I think it's better to be safe.

Wanna send a patch for that?

cheers
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help