dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Mario Limonciello" <mario.limonciello@amd.com>
Cc: linux-pci@vger.kernel.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 1/2] PCI: Preserve the initial bus number in pci_dev
Date: Tue, 20 Oct 2026 01:51:48 +0000	[thread overview]
Message-ID: <sashiko-outbox-178418@kernel.org> (raw)
In-Reply-To: <20261019-vfct-regression-v1-1-5a63ddd378dd@amd.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] PCI: NULL pointer dereference in pci_alloc_dev() when bus is NULL
--

commit 8257f74f7a4f8e2e670cc3291997e9d0a2cd7a56
Author: Mario Limonciello <mario.limonciello@amd.com>

PCI: Preserve the initial bus number in pci_dev

This commit adds an initial_bus_number field to struct pci_dev and populates
it during pci_alloc_dev() so drivers can match devices using their initial
firmware-visible bus number even after bus number reassignment.

> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index 27008e2ea5afc..580b288d5c64f 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -2508,6 +2508,7 @@ struct pci_dev *pci_alloc_dev(struct pci_bus *bus)
>  	INIT_LIST_HEAD(&dev->bus_list);
>  	dev->dev.type = &pci_dev_type;
>  	dev->bus = pci_bus_get(bus);
> +	dev->initial_bus_number = bus->number;

[Severity: High]
Can bus be NULL here?

pci_bus_get() in drivers/pci/bus.c explicitly checks if bus is NULL before
dereferencing it:

struct pci_bus *pci_bus_get(struct pci_bus *bus)
{
	if (bus)
		get_device(&bus->dev);
	return bus;
}

There are also several in-tree callers that pass NULL to pci_alloc_dev(),
such as make_local_pdev() in drivers/scsi/megaraid.c, alpha_core_agp_setup()
in drivers/char/agp/alpha-agp.c, and parisc_agp_setup() in
drivers/char/agp/parisc-agp.c:

	*pdev = pci_alloc_dev(NULL);

Wouldn't dereferencing bus->number unconditionally in pci_alloc_dev() cause
a NULL pointer dereference for these callers?

>  	dev->driver_exclusive_resource = (struct resource) {
>  		.name = "PCI Exclusive",
>  		.start = 0,

[ ... ]

>
>

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261019-vfct-regression-v1-0-5a63ddd378dd@amd.com?part=1

  reply	other threads:[~2026-10-20  1:52 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-20  1:44 [PATCH 0/2] Fix amdgpu detection of pci=realloc Mario Limonciello
2026-10-20  1:44 ` [PATCH 1/2] PCI: Preserve the initial bus number in pci_dev Mario Limonciello
2026-10-20  1:51   ` sashiko-bot [this message]
2026-10-20  1:44 ` [PATCH 2/2] drm/amdgpu: Match VFCT using initial PCI bus number Mario Limonciello
2026-10-20  1:53   ` sashiko-bot
2026-10-20 13:18   ` Deucher, Alexander
2026-10-20  2:06 ` [PATCH 0/2] Fix amdgpu detection of pci=realloc Mario Limonciello

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=sashiko-outbox-178418@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=mario.limonciello@amd.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox