[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240328180126.23574-1-amishin@t-argos.ru>
Date: Thu, 28 Mar 2024 21:01:26 +0300
From: Aleksandr Mishin <amishin@...rgos.ru>
To: Jonathan Chocron <jonnyc@...zon.com>
CC: Aleksandr Mishin <amishin@...rgos.ru>, Lorenzo Pieralisi
<lpieralisi@...nel.org>, Krzysztof WilczyĆski
<kw@...ux.com>, Rob Herring <robh@...nel.org>, Bjorn Helgaas
<bhelgaas@...gle.com>, <linux-pci@...r.kernel.org>,
<linux-kernel@...r.kernel.org>, <lvc-project@...uxtesting.org>
Subject: [PATCH] PCI: dwc: Fix potential NULL dereference
In al_pcie_config_prepare() 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/pcie-al.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/pci/controller/dwc/pcie-al.c b/drivers/pci/controller/dwc/pcie-al.c
index 6dfdda59f328..29bc99d48295 100644
--- a/drivers/pci/controller/dwc/pcie-al.c
+++ b/drivers/pci/controller/dwc/pcie-al.c
@@ -252,7 +252,12 @@ static void al_pcie_config_prepare(struct al_pcie *pcie)
u8 secondary_bus;
u32 cfg_control;
u32 reg;
- struct resource *bus = resource_list_first_type(&pp->bridge->windows, IORESOURCE_BUS)->res;
+
+ struct resource_entry *ft = resource_list_first_type(&pp->bridge->windows, IORESOURCE_BUS);
+ if (!ft)
+ return;
+
+ struct resource *bus = ft->res;
target_bus_cfg = &pcie->target_bus_cfg;
--
2.30.2
Powered by blists - more mailing lists