linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] pci: pcie-xilinx: fix a missing-check bug for __get_free_pages
@ 2019-03-14  5:58 Kangjie Lu
  2019-03-22 16:26 ` Steven Price
  0 siblings, 1 reply; 8+ messages in thread
From: Kangjie Lu @ 2019-03-14  5:58 UTC (permalink / raw)
  To: kjlu
  Cc: pakki001, Lorenzo Pieralisi, Bjorn Helgaas, Michal Simek,
	linux-pci, linux-arm-kernel, linux-kernel

In case __get_free_pages fail, the fix returns to avoid NULL
pointer dereference.

Signed-off-by: Kangjie Lu <kjlu@umn.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


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

end of thread, other threads:[~2019-03-29 16:37 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-14  5:58 [PATCH] pci: pcie-xilinx: fix a missing-check bug for __get_free_pages Kangjie Lu
2019-03-22 16:26 ` Steven Price
2019-03-25 21:31   ` [PATCH v2] " Kangjie Lu
2019-03-25 21:51     ` Bjorn Helgaas
2019-03-25 22:19       ` [PATCH v3] PCI: xilinx: Check for __get_free_pages() failure Kangjie Lu
2019-03-26 11:40         ` Steven Price
2019-03-27 13:36         ` Mukesh Ojha
2019-03-29 16:36         ` Lorenzo Pieralisi

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 NNTP newsgroup(s).