Re: [PATCH] PCI: mediatek-gen3: Fix refcount leak in mtk_pcie_init_irq_domains

Miles Chen
2022-05-30T07:36:12Z

Hi Miaoqian,

>Hi, Miles
>
>On 2022/5/30 10:19, Miles Chen wrote:
>> Hi Miaoqian,
>>
>>>>> &intx_domain_ops, pcie);
>>>>> if (!pcie->intx_domain) {
>>>>> dev_err(dev, "failed to create INTx IRQ domain\n");
>>>>> + of_node_put(intc_node);
>>>>> return -ENODEV;
>>>>> }
>>>> Thanks for doing this.
>>>>
>>>> I checked mtk_pcie_init_irq_domains() and there are multiple exit paths like
>>>> err_msi_domain and err_msi_bottom_domain and the normal path which also
>>>> need of_node_put(intc_node).
>>> Thanks for your reply,
>>>
>>> I didn't add of_node_put() in other paths because I am not sure if the reference passed through irq_domain_add_linear(), since intc_node is passed to irq_domain_add_linear().
>>>
>>> __irq_domain_add() keeps &node->fwnode in the irq_domain structure.
>>>
>>> and use fwnode_handle_get() to get the reference of fwnode, but I still uncertain.
>>>
>>> If the reference don't needed anymore after irq_domain_add_linear(),
>>>
>>> your suggestion looks fine, and I will submit v2.
>>
>> Thanks for your reply, I think we can do similar things like
>> rtl8365mb_irq_setup() in drivers/net/dsa/realtek/rtl8365mb.c
>
>I checked rtl8365mb_irq_setup(), it calls of_node_put() by goto statement for error paths.
>
>and calls of_node_put() before return 0 in normal path. I didn't see the same problem.

Sorry for the confusing. I meant that we can do the same thing -
it calls of_node_put() by goto statement for error paths
and calls of_node_put() before return 0 in normal path. :-)

Thanks,
Miles