[PATCH v2 1/2] PCI: of: Fix OF device node refcount leakage in API of_irq_parse_and_map_pci()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Zijun Hu <zijun.hu@xxxxxxxxxxxxxxxx>

Successful of_irq_parse_pci() invocation will increase refcount of
OF device node @oirq.np, but API of_irq_parse_and_map_pci() does not
decrease the refcount before return, so cause @oirq.np refcount leakage.

Fix by using OF __free() to decrease the refcount.

Signed-off-by: Zijun Hu <zijun.hu@xxxxxxxxxxxxxxxx>
Cc: Rob Herring (Arm) <robh@xxxxxxxxxx>
---
 drivers/pci/of.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/pci/of.c b/drivers/pci/of.c
index 3579265f119845637e163d9051437c89662762f8..fd6596b251246c3b64b2558c67652d01f142c785 100644
--- a/drivers/pci/of.c
+++ b/drivers/pci/of.c
@@ -576,6 +576,7 @@ static int of_irq_parse_pci(const struct pci_dev *pdev, struct of_phandle_args *
  */
 int of_irq_parse_and_map_pci(const struct pci_dev *dev, u8 slot, u8 pin)
 {
+	struct device_node *np __free(device_node) = NULL;
 	struct of_phandle_args oirq;
 	int ret;
 
@@ -583,6 +584,7 @@ int of_irq_parse_and_map_pci(const struct pci_dev *dev, u8 slot, u8 pin)
 	if (ret)
 		return 0; /* Proper return code 0 == NO_IRQ */
 
+	np = oirq.np;
 	return irq_create_of_mapping(&oirq);
 }
 EXPORT_SYMBOL_GPL(of_irq_parse_and_map_pci);

-- 
2.34.1





[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux