]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-4.19/pci-xilinx-check-for-__get_free_pages-failure.patch
Linux 5.1.10
[thirdparty/kernel/stable-queue.git] / queue-4.19 / pci-xilinx-check-for-__get_free_pages-failure.patch
1 From 96ee8dcb8a1e2121f84d2e53d18a8eaf848b02bf Mon Sep 17 00:00:00 2001
2 From: Kangjie Lu <kjlu@umn.edu>
3 Date: Mon, 25 Mar 2019 17:19:09 -0500
4 Subject: PCI: xilinx: Check for __get_free_pages() failure
5
6 [ Upstream commit 699ca30162686bf305cdf94861be02eb0cf9bda2 ]
7
8 If __get_free_pages() fails, return -ENOMEM to avoid a NULL pointer
9 dereference.
10
11 Signed-off-by: Kangjie Lu <kjlu@umn.edu>
12 Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
13 Reviewed-by: Steven Price <steven.price@arm.com>
14 Reviewed-by: Mukesh Ojha <mojha@codeaurora.org>
15 Signed-off-by: Sasha Levin <sashal@kernel.org>
16 ---
17 drivers/pci/controller/pcie-xilinx.c | 12 ++++++++++--
18 1 file changed, 10 insertions(+), 2 deletions(-)
19
20 diff --git a/drivers/pci/controller/pcie-xilinx.c b/drivers/pci/controller/pcie-xilinx.c
21 index 7b1389d8e2a5..ea48cba5480b 100644
22 --- a/drivers/pci/controller/pcie-xilinx.c
23 +++ b/drivers/pci/controller/pcie-xilinx.c
24 @@ -336,14 +336,19 @@ static const struct irq_domain_ops msi_domain_ops = {
25 * xilinx_pcie_enable_msi - Enable MSI support
26 * @port: PCIe port information
27 */
28 -static void xilinx_pcie_enable_msi(struct xilinx_pcie_port *port)
29 +static int xilinx_pcie_enable_msi(struct xilinx_pcie_port *port)
30 {
31 phys_addr_t msg_addr;
32
33 port->msi_pages = __get_free_pages(GFP_KERNEL, 0);
34 + if (!port->msi_pages)
35 + return -ENOMEM;
36 +
37 msg_addr = virt_to_phys((void *)port->msi_pages);
38 pcie_write(port, 0x0, XILINX_PCIE_REG_MSIBASE1);
39 pcie_write(port, msg_addr, XILINX_PCIE_REG_MSIBASE2);
40 +
41 + return 0;
42 }
43
44 /* INTx Functions */
45 @@ -498,6 +503,7 @@ static int xilinx_pcie_init_irq_domain(struct xilinx_pcie_port *port)
46 struct device *dev = port->dev;
47 struct device_node *node = dev->of_node;
48 struct device_node *pcie_intc_node;
49 + int ret;
50
51 /* Setup INTx */
52 pcie_intc_node = of_get_next_child(node, NULL);
53 @@ -526,7 +532,9 @@ static int xilinx_pcie_init_irq_domain(struct xilinx_pcie_port *port)
54 return -ENODEV;
55 }
56
57 - xilinx_pcie_enable_msi(port);
58 + ret = xilinx_pcie_enable_msi(port);
59 + if (ret)
60 + return ret;
61 }
62
63 return 0;
64 --
65 2.20.1
66