]> www.infradead.org Git - users/jedix/linux-maple.git/commit
of/irq: Fix device node refcount leakage in API of_irq_parse_one()
authorZijun Hu <quic_zijuhu@quicinc.com>
Sun, 9 Feb 2025 12:58:55 +0000 (20:58 +0800)
committerRob Herring (Arm) <robh@kernel.org>
Tue, 25 Feb 2025 13:16:50 +0000 (07:16 -0600)
commit0cb58d6c7b558a69957fabe159bfb184196e1e8d
treee675b07dbce2e71a1acd091396c42820dad51250
parent65f4be07ad1010f41dbe329398da881a38051c98
of/irq: Fix device node refcount leakage in API of_irq_parse_one()

of_irq_parse_one(@int_gen_dev, i, ...) will leak refcount of @i_th_phandle

int_gen_dev {
    ...
    interrupts-extended = ..., <&i_th_phandle ...>, ...;
    ...
};

Refcount of @i_th_phandle is increased by of_parse_phandle_with_args()
but is not decreased by API of_irq_parse_one() before return, so causes
refcount leakage.

Rework the refcounting to use __free() cleanup and simplify the code to
have a single call to of_irq_parse_raw().

Also add comments about refcount of node @out_irq->np got by the API.

Fixes: 79d9701559a9 ("of/irq: create interrupts-extended property")
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-2-93e3a2659aa7@quicinc.com
[robh: Use __free() to do puts]
Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
drivers/of/irq.c