[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190314055851.6884-1-kjlu@umn.edu>
Date: Thu, 14 Mar 2019 00:58:51 -0500
From: Kangjie Lu <kjlu@....edu>
To: kjlu@....edu
Cc: pakki001@....edu, Lorenzo Pieralisi <lorenzo.pieralisi@....com>,
Bjorn Helgaas <bhelgaas@...gle.com>,
Michal Simek <michal.simek@...inx.com>,
linux-pci@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
linux-kernel@...r.kernel.org
Subject: [PATCH] pci: pcie-xilinx: fix a missing-check bug for __get_free_pages
In case __get_free_pages fail, the fix returns to avoid NULL
pointer dereference.
Signed-off-by: Kangjie Lu <kjlu@....edu>
---
drivers/pci/controller/pcie-xilinx.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/pci/controller/pcie-xilinx.c b/drivers/pci/controller/pcie-xilinx.c
index 9bd1a35cd5d8..b7083e995c45 100644
--- a/drivers/pci/controller/pcie-xilinx.c
+++ b/drivers/pci/controller/pcie-xilinx.c
@@ -341,6 +341,9 @@ static void xilinx_pcie_enable_msi(struct xilinx_pcie_port *port)
phys_addr_t msg_addr;
port->msi_pages = __get_free_pages(GFP_KERNEL, 0);
+ if (unlikely(!port->msi_pages))
+ return;
+
msg_addr = virt_to_phys((void *)port->msi_pages);
pcie_write(port, 0x0, XILINX_PCIE_REG_MSIBASE1);
pcie_write(port, msg_addr, XILINX_PCIE_REG_MSIBASE2);
--
2.17.1
Powered by blists - more mailing lists