Skip to content

Commit dc93728

Browse files
author
Rob Herring
committed
of/irq: of_irq_find_parent: check for parent equal to child
An interrupt controller may often implicitly inherit itself from a parent node when in fact the controller is the interrupt root controller. Guard against the case of child == parent and return NULL in this case. This can also be fixed by adding an explicit "interrupt-parent;" to a root interrupt controller node. Based on code from Grant Likely. Signed-off-by: Rob Herring <[email protected]> Cc: Grant Likely <[email protected]>
1 parent f910b83 commit dc93728

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

drivers/of/irq.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,27 +58,27 @@ EXPORT_SYMBOL_GPL(irq_of_parse_and_map);
5858
*/
5959
struct device_node *of_irq_find_parent(struct device_node *child)
6060
{
61-
struct device_node *p;
61+
struct device_node *p, *c = child;
6262
const __be32 *parp;
6363

64-
if (!of_node_get(child))
64+
if (!of_node_get(c))
6565
return NULL;
6666

6767
do {
68-
parp = of_get_property(child, "interrupt-parent", NULL);
68+
parp = of_get_property(c, "interrupt-parent", NULL);
6969
if (parp == NULL)
70-
p = of_get_parent(child);
70+
p = of_get_parent(c);
7171
else {
7272
if (of_irq_workarounds & OF_IMAP_NO_PHANDLE)
7373
p = of_node_get(of_irq_dflt_pic);
7474
else
7575
p = of_find_node_by_phandle(be32_to_cpup(parp));
7676
}
77-
of_node_put(child);
78-
child = p;
77+
of_node_put(c);
78+
c = p;
7979
} while (p && of_get_property(p, "#interrupt-cells", NULL) == NULL);
8080

81-
return p;
81+
return (p == child) ? NULL : p;
8282
}
8383

8484
/**

0 commit comments

Comments
 (0)