From: Zijun Hu <zijun_hu@icloud.com>
To: Bjorn Helgaas <bhelgaas@google.com>,
Rob Herring <robh@kernel.org>, Lizhi Hou <lizhi.hou@amd.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Zijun Hu <zijun_hu@icloud.com>,
linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
Zijun Hu <quic_zijuhu@quicinc.com>,
Zijun Hu <zijun.hu@oss.qualcomm.com>
Subject: [PATCH v2 1/2] PCI: of: Fix OF device node refcount leakage in API of_irq_parse_and_map_pci()
Date: Mon, 23 Jun 2025 21:17:38 +0800 [thread overview]
Message-ID: <20250623-fix_of_pci-v2-1-5bbb65190d47@oss.qualcomm.com> (raw)
In-Reply-To: <20250623-fix_of_pci-v2-0-5bbb65190d47@oss.qualcomm.com>
From: Zijun Hu <zijun.hu@oss.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@oss.qualcomm.com>
Cc: Rob Herring (Arm) <robh@kernel.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
next prev parent reply other threads:[~2025-06-23 13:18 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-23 13:17 [PATCH v2 0/2] PCI: of: Fix OF device node refcount leakages Zijun Hu
2025-06-23 13:17 ` Zijun Hu [this message]
2025-06-23 13:17 ` [PATCH v2 2/2] PCI: of: Fix OF device node refcount leakages in of_pci_prop_intr_map() Zijun Hu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250623-fix_of_pci-v2-1-5bbb65190d47@oss.qualcomm.com \
--to=zijun_hu@icloud.com \
--cc=bhelgaas@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lizhi.hou@amd.com \
--cc=quic_zijuhu@quicinc.com \
--cc=robh@kernel.org \
--cc=zijun.hu@oss.qualcomm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®