[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240329051947.28900-1-amishin@t-argos.ru>
Date: Fri, 29 Mar 2024 08:19:47 +0300
From: Aleksandr Mishin <amishin@...rgos.ru>
To: Rob Herring <robh@...nel.org>
CC: Aleksandr Mishin <amishin@...rgos.ru>, Lorenzo Pieralisi
<lpieralisi@...nel.org>, Krzysztof Wilczyński
<kw@...ux.com>, Bjorn Helgaas <bhelgaas@...gle.com>, Manivannan Sadhasivam
<manivannan.sadhasivam@...aro.org>, Uwe Kleine-König
<u.kleine-koenig@...gutronix.de>, Serge Semin <fancer.lancer@...il.com>,
Niklas Cassel <cassel@...nel.org>, Yoshihiro Shimoda
<yoshihiro.shimoda.uh@...esas.com>, Damien Le Moal <dlemoal@...nel.org>,
Siddharth Vadapalli <s-vadapalli@...com>, <linux-pci@...r.kernel.org>,
<linux-kernel@...r.kernel.org>, <lvc-project@...uxtesting.org>
Subject: [PATCH] PCI: dwc: keystone: Fix potential NULL dereference
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@...rgos.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
Powered by blists - more mailing lists