Re: [PATCH] PCI: pciehp: Fix NULL pointer dereference in pciehp_configure_device()
From: Niklas Schnelle
Date: Tue Nov 10 2026 - 12:12:21 EST
On Tue, 2026-11-10 at 11:04 +0100, Lukas Wunner wrote:
> On Mon, Nov 09, 2026 at 09:53:38PM +0000, Priyank Rathod wrote:
> > On Mon, Oct 12, 2026 at 10:16:29PM +0000, sashiko-bot@xxxxxxxxxx wrote:
> > > While this allows devices without Function 0 to be successfully hot-added,
> > > will it lead to spurious teardowns upon system resume?
> > ...
> > > Could this spurious teardown issue be avoided by modifying
> > > pciehp_device_replaced() to handle missing Function 0 devices correctly?
> [...]
> > Regarding the bot's question above: pciehp assumes Function 0
> > (PCI_DEVFN(0, 0)) represents an occupied slot across all four of its
> > lookup sites -- the -EEXIST check at the top of
> > pciehp_configure_device(), pcie_init(), pciehp_device_replaced(), and
> > the DSN read at the end of pciehp_configure_device() (consistent with
> > PCIe r6.3 sec 7.9.3 requiring Multi-Function Devices implementing DSN to
> > expose it on Function 0).
>
> I'm not even sure whether pciehp is actually used with jailhouse,
> s390 or loongarch. pciehp assumes in multiple places that function 0
> is present, so guarding against a missing function 0 in a single place
> doesn't really make sense.
>
> Note that there's a patch pending which moves the cached dsn from
> pciehp's struct controller to struct pci_dev, so the days are numbered
> for the lines you're changing:
>
> https://lore.kernel.org/r/20260902133933.2992457-7-terry.bowman@xxxxxxx/
>
> Are you actually observing a crash in practice because of a missing NULL
> pointer check?
>
> Thanks,
>
> Lukas
FWIW we (s390) do not use pciehp we use our own s390_pci_hpc for
hotplug. I'd be interested if this comes out of a real issue or just an
LLM worry too though.
Thanks,
Niklas