public inbox for linux-pci@vger.kernel.org
 help / color / mirror / Atom feed
From: Bjorn Helgaas <helgaas@kernel.org>
To: Sergey Shtylyov <s.shtylyov@auroraos.dev>
Cc: "Bjorn Helgaas" <bhelgaas@google.com>,
	linux-pci@vger.kernel.org, "Pali Rohár" <pali@kernel.org>
Subject: Re: [PATCH] PCI: Check parent for NULL in of_pci_bus_release_domain_nr()
Date: Thu, 29 Jan 2026 12:31:28 -0600	[thread overview]
Message-ID: <20260129183128.GA471057@bhelgaas> (raw)
In-Reply-To: <20260127203944.28588-1-s.shtylyov@auroraos.dev>

On Tue, Jan 27, 2026 at 11:39:42PM +0300, Sergey Shtylyov wrote:
> of_pci_bus_find_domain_nr() allows its parent parameter to be NULL but
> of_pci_bus_release_domain_nr() (that undoes its effect) doesn't -- that
> means it's going to blow up while calling of_get_pci_domain_nr() if the
> parent parameter indeed happens to be NULL.  Add the missing NULL check.
> 
> Found by Linux Verification Center (linuxtesting.org) with the Svace static
> analysis tool.
> 
> Fixes: c14f7ccc9f5d ("PCI: Assign PCI domain IDs by ida_alloc()")
> Signed-off-by: Sergey Shtylyov <s.shtylyov@auroraos.dev>

Applied to pci/enumeration for v6.20, thanks!

> ---
>  drivers/pci/pci.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index 13dbb405dc31..9fc4c2226b03 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -6591,7 +6591,7 @@ static void of_pci_bus_release_domain_nr(struct device *parent, int domain_nr)
>  		return;
>  
>  	/* Release domain from IDA where it was allocated. */
> -	if (of_get_pci_domain_nr(parent->of_node) == domain_nr)
> +	if (parent && of_get_pci_domain_nr(parent->of_node) == domain_nr)
>  		ida_free(&pci_domain_nr_static_ida, domain_nr);
>  	else
>  		ida_free(&pci_domain_nr_dynamic_ida, domain_nr);
> -- 
> 2.52.0
> 

      parent reply	other threads:[~2026-01-29 18:31 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-27 20:39 [PATCH] PCI: Check parent for NULL in of_pci_bus_release_domain_nr() Sergey Shtylyov
2026-01-28 19:34 ` Sergey Shtylyov
2026-01-29 18:31 ` Bjorn Helgaas [this message]

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=20260129183128.GA471057@bhelgaas \
    --to=helgaas@kernel.org \
    --cc=bhelgaas@google.com \
    --cc=linux-pci@vger.kernel.org \
    --cc=pali@kernel.org \
    --cc=s.shtylyov@auroraos.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox