Skip to content

Commit a53c4dc

Browse files
svenpeter42marcan
authored andcommitted
PCI: apple: Initialize pcie->nvecs before using it
apple_pcie_setup_port computes ilog2(pcie->nvecs) to setup the number of MSIs available for each port. It is however called before apple_msi_init which actually initializes pcie->nvecs. Luckily, pcie->nvecs is part of kzalloc-ed structure and thus initialized as zero. ilog2(0) happens to be 0xffffffff which then just configures more MSIs in hardware than we actually have. This doesn't break anything because we never hand out those vectors. Let's swap the order of the two calls so that we use the correctly initialized value. Fixes: 476c41e ("PCI: apple: Implement MSI support") Signed-off-by: Sven Peter <[email protected]> Reviewed-by: Marc Zyngier <[email protected]> Reviewed-by: Eric Curtin <[email protected]> Reviewed-by: Alyssa Rosenzweig <[email protected]>
1 parent 15f4442 commit a53c4dc

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

drivers/pci/controller/pcie-apple.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -828,6 +828,10 @@ static int apple_pcie_init(struct pci_config_window *cfg)
828828
cfg->priv = pcie;
829829
INIT_LIST_HEAD(&pcie->ports);
830830

831+
ret = apple_msi_init(pcie);
832+
if (ret)
833+
return ret;
834+
831835
for_each_available_child_of_node(dev->of_node, of_port) {
832836
ret = apple_pcie_setup_port(pcie, of_port);
833837
if (ret) {
@@ -837,7 +841,7 @@ static int apple_pcie_init(struct pci_config_window *cfg)
837841
}
838842
}
839843

840-
return apple_msi_init(pcie);
844+
return 0;
841845
}
842846

843847
static int apple_pcie_probe(struct platform_device *pdev)

0 commit comments

Comments
 (0)