Skip to content

Commit

Permalink
of/irq: Fix device node refcount leakage in API irq_of_parse_and_map()
Browse files Browse the repository at this point in the history
In irq_of_parse_and_map(), refcount of device node @oirq.np was got
by successful of_irq_parse_one() invocation, but it does not put the
refcount before return, so causes @oirq.np refcount leakage.

Fix by putting @oirq.np refcount before return.

Fixes: e387344 ("of/irq: Move irq_of_parse_and_map() to common code")
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-6-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 bbf71f4 commit 962a280
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion drivers/of/irq.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,15 @@
unsigned int irq_of_parse_and_map(struct device_node *dev, int index)
{
struct of_phandle_args oirq;
unsigned int ret;

if (of_irq_parse_one(dev, index, &oirq))
return 0;

return irq_create_of_mapping(&oirq);
ret = irq_create_of_mapping(&oirq);
of_node_put(oirq.np);

return ret;
}
EXPORT_SYMBOL_GPL(irq_of_parse_and_map);

Expand Down

0 comments on commit 962a280

Please sign in to comment.