Skip to content

Commit

Permalink
of/irq: Fix device node refcount leakages in of_irq_count()
Browse files Browse the repository at this point in the history
of_irq_count() invokes of_irq_parse_one() to count IRQs, and successful
invocation of the later will get device node @irq.np refcount, but the
former does not put the refcount before next iteration invocation, hence
causes device node refcount leakages.

Fix by putting @irq.np refcount before the next iteration invocation.

Fixes: 3da5278 ("of/irq: Rework of_irq_count()")
Cc: stable@vger.kernel.org
Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
Link: https://lore.kernel.org/r/20250209-of_irq_fix-v2-5-93e3a2659aa7@quicinc.com
Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
  • Loading branch information
Zijun Hu authored and Rob Herring (Arm) committed Feb 25, 2025
1 parent ff93e72 commit bbf71f4
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/of/irq.c
Original file line number Diff line number Diff line change
Expand Up @@ -508,8 +508,10 @@ int of_irq_count(struct device_node *dev)
struct of_phandle_args irq;
int nr = 0;

while (of_irq_parse_one(dev, nr, &irq) == 0)
while (of_irq_parse_one(dev, nr, &irq) == 0) {
of_node_put(irq.np);
nr++;
}

return nr;
}
Expand Down

0 comments on commit bbf71f4

Please sign in to comment.