Skip to content

Commit 17d7c85

Browse files
kengiterLee Jones
authored andcommitted
PCI: xilinx: Check for __get_free_pages() failure
[ Upstream commit 699ca30 ] If __get_free_pages() fails, return -ENOMEM to avoid a NULL pointer dereference. Signed-off-by: Kangjie Lu <kjlu@umn.edu> Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> Reviewed-by: Steven Price <steven.price@arm.com> Reviewed-by: Mukesh Ojha <mojha@codeaurora.org> Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Lee Jones <lee.jones@linaro.org> Change-Id: I711fae052f6312ab9a49694aa8b9d0ff88281719
1 parent 0c5a810 commit 17d7c85

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

drivers/pci/host/pcie-xilinx.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,14 +421,19 @@ static const struct irq_domain_ops msi_domain_ops = {
421421
* xilinx_pcie_enable_msi - Enable MSI support
422422
* @port: PCIe port information
423423
*/
424-
static void xilinx_pcie_enable_msi(struct xilinx_pcie_port *port)
424+
static int xilinx_pcie_enable_msi(struct xilinx_pcie_port *port)
425425
{
426426
phys_addr_t msg_addr;
427427

428428
port->msi_pages = __get_free_pages(GFP_KERNEL, 0);
429+
if (!port->msi_pages)
430+
return -ENOMEM;
431+
429432
msg_addr = virt_to_phys((void *)port->msi_pages);
430433
pcie_write(port, 0x0, XILINX_PCIE_REG_MSIBASE1);
431434
pcie_write(port, msg_addr, XILINX_PCIE_REG_MSIBASE2);
435+
436+
return 0;
432437
}
433438

434439
/**
@@ -639,6 +644,7 @@ static int xilinx_pcie_init_irq_domain(struct xilinx_pcie_port *port)
639644
struct device *dev = port->dev;
640645
struct device_node *node = dev->of_node;
641646
struct device_node *pcie_intc_node;
647+
int ret;
642648

643649
/* Setup INTx */
644650
pcie_intc_node = of_get_next_child(node, NULL);
@@ -666,7 +672,9 @@ static int xilinx_pcie_init_irq_domain(struct xilinx_pcie_port *port)
666672
return PTR_ERR(port->irq_domain);
667673
}
668674

669-
xilinx_pcie_enable_msi(port);
675+
ret = xilinx_pcie_enable_msi(port);
676+
if (ret)
677+
return ret;
670678
}
671679

672680
return 0;

0 commit comments

Comments
 (0)