]>
Commit | Line | Data |
---|---|---|
cd033818 SL |
1 | From 55ffde78a6abd040b7080868c92c506599ad2199 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/host/pcie-xilinx.c | 12 ++++++++++-- | |
18 | 1 file changed, 10 insertions(+), 2 deletions(-) | |
19 | ||
20 | diff --git a/drivers/pci/host/pcie-xilinx.c b/drivers/pci/host/pcie-xilinx.c | |
21 | index 4cfa46360d12..6a2499f4d610 100644 | |
22 | --- a/drivers/pci/host/pcie-xilinx.c | |
23 | +++ b/drivers/pci/host/pcie-xilinx.c | |
24 | @@ -349,14 +349,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 | @@ -555,6 +560,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 | @@ -582,7 +588,9 @@ static int xilinx_pcie_init_irq_domain(struct xilinx_pcie_port *port) | |
54 | return PTR_ERR(port->irq_domain); | |
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 |