lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250623-fix_of_pci-v2-1-5bbb65190d47@oss.qualcomm.com>
Date: Mon, 23 Jun 2025 21:17:38 +0800
From: Zijun Hu <zijun_hu@...oud.com>
To: Bjorn Helgaas <bhelgaas@...gle.com>, Rob Herring <robh@...nel.org>, 
 Lizhi Hou <lizhi.hou@....com>
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>, 
 Zijun Hu <zijun_hu@...oud.com>, linux-pci@...r.kernel.org, 
 linux-kernel@...r.kernel.org, Zijun Hu <quic_zijuhu@...cinc.com>, 
 Zijun Hu <zijun.hu@....qualcomm.com>
Subject: [PATCH v2 1/2] PCI: of: Fix OF device node refcount leakage in API
 of_irq_parse_and_map_pci()

From: Zijun Hu <zijun.hu@....qualcomm.com>

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@....qualcomm.com>
Cc: Rob Herring (Arm) <robh@...nel.org>
---
 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


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ