Re: [PATCH v1 19/19] PCI/ERR: Avoid NULL bridge pointer

From: Pierre Gondois

Date: Wed Nov 18 2026 - 10:12:53 EST


Hello Lukas, Kuppuswamy,

On 11/17/26 19:57, Kuppuswamy Sathyanarayanan wrote:

On 11/17/26 03:50, Lukas Wunner wrote:
On Tue, Nov 17, 2026 at 12:10:29PM +0100, Pierre Gondois wrote:
Return PCI_ERS_RESULT_DISCONNECT when no upstream bridge is available,
avoiding a NULL pointer dereference in pci_walk_bridge().
How can that happen? If it can happen (which I doubt), why isn't this
patch tagged for stable?
One way I can see is a device without a PCIe capability on a root bus.
pci_pcie_type() returns 0, which is PCI_EXP_TYPE_ENDPOINT, and
pci_upstream_bridge() returns NULL. Native AER never gets there. Only
firmware-first can, through aer_recover_work_func(), and only if
firmware reports a PCIe error section for such a device. If that is
the case, skipping recovery for !pci_is_pcie(pdev) in
aer_recover_work_func() seems a better fit than a check in
pcie_do_recovery().

Why is it at the end of this series? Does the series somehow make it
possible that there's no upstream bridge? Which patch does that?
If the preceding patches are not the cause of a potential NULL
pointer deref, why isn't this patch submitted separately from the series?

To test this serie, I generated and injected synthetic CPER records.
The PCI device referenced in some synthetic CPER records did not
actually exist. In such case, the kernel crashes due to a NULL
pointer deferencement.

This use case is indeed slightly unsusual and unlikely to happen
in the real world. The patch was still included in the serie.

Please let me know if the patch should be either dropped or better
documented.