From: Nam Cao <namcao@linutronix.de>
To: Bjorn Helgaas <bhelgaas@google.com>,
Yinghai Lu <yinghai@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Rajesh Shah <rajesh.shah@intel.com>,
linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Nam Cao <namcao@linutronix.de>, stable@vger.kernel.org
Subject: [PATCH 1/4] PCI: shpchp: bail out if pci_hp_add_bridge() fails
Date: Fri, 3 May 2024 21:23:19 +0200 [thread overview]
Message-ID: <da60d5a41e8e554ca98d8d9b61e73291495bf820.1714762038.git.namcao@linutronix.de> (raw)
In-Reply-To: <cover.1714762038.git.namcao@linutronix.de>
If there is no bus number available for the downstream bus of the
hot-plugged bridge, pci_hp_add_bridge() will fail. The driver proceeds
regardless, and the kernel crashes.
Abort if pci_hp_add_bridge() fails.
Fixes: 7d01f70ac6f4 ("PCI: shpchp: use generic pci_hp_add_bridge()")
Signed-off-by: Nam Cao <namcao@linutronix.de>
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: <stable@vger.kernel.org>
---
drivers/pci/hotplug/shpchp_pci.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/pci/hotplug/shpchp_pci.c b/drivers/pci/hotplug/shpchp_pci.c
index 36db0c3c4ea6..2ac98bdc83d9 100644
--- a/drivers/pci/hotplug/shpchp_pci.c
+++ b/drivers/pci/hotplug/shpchp_pci.c
@@ -48,8 +48,13 @@ 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) {
+ if (pci_hp_add_bridge(dev)) {
+ pci_stop_and_remove_bus_device(dev);
+ ret = -EINVAL;
+ goto out;
+ }
+ }
}
pci_assign_unassigned_bridge_resources(bridge);
--
2.39.2
next prev parent reply other threads:[~2024-05-03 19:23 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-03 19:23 [PATCH 0/4] check returned value of pci_hp_add_bridge() Nam Cao
2024-05-03 19:23 ` Nam Cao [this message]
2024-05-03 19:23 ` [PATCH 2/4] PCI: pciehp: bail out if pci_hp_add_bridge() fails Nam Cao
2024-05-03 21:23 ` Bjorn Helgaas
2024-05-03 21:41 ` Nam Cao
2024-05-04 8:54 ` Lukas Wunner
2024-05-04 9:35 ` Nam Cao
2024-05-04 9:51 ` Lukas Wunner
2024-05-04 10:56 ` Nam Cao
2024-05-04 15:02 ` Lukas Wunner
2024-05-04 15:48 ` Nam Cao
2024-05-03 19:23 ` [PATCH 3/4] PCI: hotplug: document unchecked return value of pci_hp_add_bridge() Nam Cao
2024-05-03 19:23 ` [PATCH 4/4] PCI: hotplug: remove TODO notes for sgi_hotplug Nam Cao
2024-05-03 21:29 ` [PATCH 0/4] check returned value of pci_hp_add_bridge() Bjorn Helgaas
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=da60d5a41e8e554ca98d8d9b61e73291495bf820.1714762038.git.namcao@linutronix.de \
--to=namcao@linutronix.de \
--cc=bhelgaas@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=rajesh.shah@intel.com \
--cc=stable@vger.kernel.org \
--cc=yinghai@kernel.org \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).