public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] PCI: dwc: keystone: Fix potential NULL dereference
@ 2024-03-29  5:19 Aleksandr Mishin
  2024-04-02 17:31 ` Bjorn Helgaas
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: Aleksandr Mishin @ 2024-03-29  5:19 UTC (permalink / raw)
  To: Rob Herring
  Cc: Aleksandr Mishin, Lorenzo Pieralisi, Krzysztof Wilczyński,
	Bjorn Helgaas, Manivannan Sadhasivam, Uwe Kleine-König,
	Serge Semin, Niklas Cassel, Yoshihiro Shimoda, Damien Le Moal,
	Siddharth Vadapalli, linux-pci, linux-kernel, lvc-project

In ks_pcie_setup_rc_app_regs() resource_list_first_type() may return
NULL which is later dereferenced. Fix this bug by adding NULL check.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: 0f71c60ffd26 ("PCI: dwc: Remove storing of PCI resources")
Signed-off-by: Aleksandr Mishin <amishin@t-argos.ru>
---
 drivers/pci/controller/dwc/pci-keystone.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/controller/dwc/pci-keystone.c b/drivers/pci/controller/dwc/pci-keystone.c
index 844de4418724..00d616654171 100644
--- a/drivers/pci/controller/dwc/pci-keystone.c
+++ b/drivers/pci/controller/dwc/pci-keystone.c
@@ -392,7 +392,11 @@ static void ks_pcie_setup_rc_app_regs(struct keystone_pcie *ks_pcie)
 	struct resource *mem;
 	int i;
 
-	mem = resource_list_first_type(&pp->bridge->windows, IORESOURCE_MEM)->res;
+	struct resource_entry *ft = resource_list_first_type(&pp->bridge->windows, IORESOURCE_MEM);
+	if (!ft)
+		return;
+
+	mem = ft->res;
 	start = mem->start;
 	end = mem->end;
 
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2024-05-17 17:13 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-29  5:19 [PATCH] PCI: dwc: keystone: Fix potential NULL dereference Aleksandr Mishin
2024-04-02 17:31 ` Bjorn Helgaas
2024-04-25  9:21 ` [PATCH v2] " Aleksandr Mishin
2024-04-25 13:00   ` Alexander Lobakin
2024-04-26 22:47     ` Bjorn Helgaas
2024-04-27  8:44     ` Manivannan Sadhasivam
2024-04-27  8:47   ` Manivannan Sadhasivam
2024-04-29  6:53   ` Niklas Cassel
2024-05-03 12:57 ` [PATCH v3] PCI: dwc: keystone: Fix NULL pointer dereference in case of DT error in ks_pcie_setup_rc_app_regs() Aleksandr Mishin
2024-05-04 17:01   ` Manivannan Sadhasivam
2024-05-05  6:15 ` [PATCH v4] " Aleksandr Mishin
2024-05-17 17:13   ` Krzysztof Wilczyński

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox