All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Alex Elder" <elder@riscstar.com>
Cc: robh@kernel.org, linux-pci@vger.kernel.org, conor+dt@kernel.org,
	devicetree@vger.kernel.org
Subject: Re: [PATCH v5 2/4] PCI: of: drop the reg_num argument to of_pci_set_address()
Date: Tue, 08 Sep 2026 21:46:01 +0000	[thread overview]
Message-ID: <20260908214601.7716D1F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260908213459.2519059-3-elder@riscstar.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Leaked OF node reference counts in of_pci_prop_intr_map()
--

commit b3af32f45eed6da355a4a96246bdedb364fe0855
Author: Alex Elder <elder@riscstar.com>

PCI: of: drop the reg_num argument to of_pci_set_address()

The reg_num argument passed to of_pci_set_address() is always zero,
so get rid of it.

Reviewed-by: Herve Codina <herve.codina@bootlin.com>
Signed-off-by: Alex Elder <elder@riscstar.com>

> diff --git a/drivers/pci/of_property.c b/drivers/pci/of_property.c
> index d66c702218081..1caabbd4c18b5 100644
> --- a/drivers/pci/of_property.c
> +++ b/drivers/pci/of_property.c

[ ... ]

[Severity: High]
This is a pre-existing issue, but does this code leak device node reference
counts in of_pci_prop_intr_map()?

When of_irq_parse_raw() successfully parses an interrupt, it acquires a
device node reference and stores it in out_irq[i].np:

drivers/pci/of_property.c:of_pci_prop_intr_map() {
    ...
		ret = of_irq_parse_raw(laddr, &out_irq[i]);
		if (ret) {
			out_irq[i].np = NULL;
			pci_dbg(pdev, "parse irq %d failed, ret %d", pin, ret);
			continue;
		}
    ...

However, the function returns without calling of_node_put() on the
successfully parsed nodes in the out_irq array. This leak occurs on all
return paths, such as when map_sz is zero or when kcalloc() fails:

    ...
	if (!map_sz)
		return 0;

	int_map = kcalloc(map_sz, sizeof(u32), GFP_KERNEL);
	if (!int_map)
		return -ENOMEM;
    ...

Are we missing calls to of_node_put() for these references before
returning?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260908213459.2519059-1-elder@riscstar.com?part=2

  reply	other threads:[~2026-09-08 21:46 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-08 21:34 [PATCH v5 0/4] PCI: of: warn on bogus device_type property Alex Elder
2026-09-08 21:34 ` [PATCH v5 1/4] PCI: of: avoid allocations in of_pci_prop_compatible() Alex Elder
2026-09-08 21:40   ` sashiko-bot
2026-09-08 21:34 ` [PATCH v5 2/4] PCI: of: drop the reg_num argument to of_pci_set_address() Alex Elder
2026-09-08 21:46   ` sashiko-bot [this message]
2026-09-09 13:02     ` Alex Elder
2026-09-08 21:34 ` [PATCH v5 3/4] PCI: of: don't zero flags in of_pci_get_addr_flags() Alex Elder
2026-09-08 21:38   ` sashiko-bot
2026-09-08 21:34 ` [PATCH v5 4/4] PCI: of: introduce of_pci_verify_node() Alex Elder
2026-09-08 21:39   ` sashiko-bot
2026-09-09 16:37   ` Bjorn Helgaas
2026-09-09 17:23     ` Alex Elder

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=20260908214601.7716D1F00A3A@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=elder@riscstar.com \
    --cc=linux-pci@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.