Re: [PATCH] PCI: hotplug: check the return of hotplug bridge
From: Lukas Wunner
Date: Sat Aug 17 2024 - 01:29:49 EST
[shorten subject, cc += Nam Cao, start of thread:
https://lore.kernel.org/all/20240817032228.6844-1-trintaeoitogc@xxxxxxxxx/
]
On Sat, Aug 17, 2024 at 12:22:27AM -0300, Guilherme Giacomo Simoes wrote:
> Signed-off-by: Guilherme Giacomo Simoes <trintaeoitogc@xxxxxxxxx>
Hm, the body of the commit message ended up in the subject
and the patch was submitted twice.
> --- a/drivers/pci/hotplug/shpchp_pci.c
> +++ b/drivers/pci/hotplug/shpchp_pci.c
> @@ -48,8 +48,11 @@ int shpchp_configure_device(struct slot *p_slot)
> }
>
> for_each_pci_bridge(dev, parent) {
> - if (PCI_SLOT(dev->devfn) == p_slot->device)
> - pci_hp_add_bridge(dev);
> + if (PCI_SLOT(dev->devfn) == p_slot->device) {
> + ret = pci_hp_add_bridge(dev);
> + if (ret)
> + goto out;
> + }
> }
>
> pci_assign_unassigned_bridge_resources(bridge);
Nam Cao worked on this back in May:
v1:
https://lore.kernel.org/all/cover.1714762038.git.namcao@xxxxxxxxxxxxx/
v2:
https://lore.kernel.org/all/cover.1714838173.git.namcao@xxxxxxxxxxxxx/
v3:
https://lore.kernel.org/all/cover.1715609848.git.namcao@xxxxxxxxxxxxx/
Note that there was discussion on v2 after v3 had been submitted,
i.e. the last messages in the discussion are in the v2 thread.
Nam Cao's patches didn't get applied, I think we hadn't reached
consensus or were waiting for a v4.
Nam Cao's v2 uses the exact same approach that you're proposing
and they subsequently found a way to crash the kernel despite the
newly introduced error handling:
https://lore.kernel.org/all/20240506083701.NZNifFGn@xxxxxxxxxxxxx/
So I'm afraid your patch may not work in every scenario.
Thanks,
Lukas