Skip to content

Commit 8979319

Browse files
committed
Merge tag 'pci-v4.18-fixes-2' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci
Pull PCI fixes from Bjorn Helgaas: - Fix a use-after-free in the endpoint code (Dan Carpenter) - Stop defaulting CONFIG_PCIE_DW_PLAT_HOST to yes (Geert Uytterhoeven) - Fix an nfp regression caused by a change in how we limit the number of VFs we can enable (Jakub Kicinski) - Fix failure path cleanup issues in the new R-Car gen3 PHY support (Marek Vasut) - Fix leaks of OF nodes in faraday, xilinx-nwl, xilinx (Nicholas Mc Guire) * tag 'pci-v4.18-fixes-2' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci: nfp: stop limiting VFs to 0 PCI/IOV: Reset total_VFs limit after detaching PF driver PCI: faraday: Add missing of_node_put() PCI: xilinx-nwl: Add missing of_node_put() PCI: xilinx: Add missing of_node_put() PCI: endpoint: Use after free in pci_epf_unregister_driver() PCI: controller: dwc: Do not let PCIE_DW_PLAT_HOST default to yes PCI: rcar: Clean up PHY init on failure PCI: rcar: Shut the PHY down in failpath
2 parents b2d44d1 + 8323582 commit 8979319

10 files changed

Lines changed: 41 additions & 12 deletions

File tree

‎drivers/net/ethernet/netronome/nfp/nfp_main.c‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,6 @@ static int nfp_pcie_sriov_read_nfd_limit(struct nfp_pf *pf)
240240
return pci_sriov_set_totalvfs(pf->pdev, pf->limit_vfs);
241241

242242
pf->limit_vfs = ~0;
243-
pci_sriov_set_totalvfs(pf->pdev, 0); /* 0 is unset */
244243
/* Allow any setting for backwards compatibility if symbol not found */
245244
if (err == -ENOENT)
246245
return 0;
@@ -668,7 +667,7 @@ static int nfp_pci_probe(struct pci_dev *pdev,
668667

669668
err = nfp_net_pci_probe(pf);
670669
if (err)
671-
goto err_sriov_unlimit;
670+
goto err_fw_unload;
672671

673672
err = nfp_hwmon_register(pf);
674673
if (err) {
@@ -680,8 +679,6 @@ static int nfp_pci_probe(struct pci_dev *pdev,
680679

681680
err_net_remove:
682681
nfp_net_pci_remove(pf);
683-
err_sriov_unlimit:
684-
pci_sriov_set_totalvfs(pf->pdev, 0);
685682
err_fw_unload:
686683
kfree(pf->rtbl);
687684
nfp_mip_close(pf->mip);
@@ -715,7 +712,6 @@ static void nfp_pci_remove(struct pci_dev *pdev)
715712
nfp_hwmon_unregister(pf);
716713

717714
nfp_pcie_sriov_disable(pdev);
718-
pci_sriov_set_totalvfs(pf->pdev, 0);
719715

720716
nfp_net_pci_remove(pf);
721717

‎drivers/pci/controller/dwc/Kconfig‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ config PCIE_DW_PLAT_HOST
5858
depends on PCI && PCI_MSI_IRQ_DOMAIN
5959
select PCIE_DW_HOST
6060
select PCIE_DW_PLAT
61-
default y
6261
help
6362
Enables support for the PCIe controller in the Designware IP to
6463
work in host mode. There are two instances of PCIe controller in

‎drivers/pci/controller/pci-ftpci100.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,11 +355,13 @@ static int faraday_pci_setup_cascaded_irq(struct faraday_pci *p)
355355
irq = of_irq_get(intc, 0);
356356
if (irq <= 0) {
357357
dev_err(p->dev, "failed to get parent IRQ\n");
358+
of_node_put(intc);
358359
return irq ?: -EINVAL;
359360
}
360361

361362
p->irqdomain = irq_domain_add_linear(intc, PCI_NUM_INTX,
362363
&faraday_pci_irqdomain_ops, p);
364+
of_node_put(intc);
363365
if (!p->irqdomain) {
364366
dev_err(p->dev, "failed to create Gemini PCI IRQ domain\n");
365367
return -EINVAL;

‎drivers/pci/controller/pcie-rcar.c‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,11 @@ static int rcar_pcie_phy_init_gen3(struct rcar_pcie *pcie)
680680
if (err)
681681
return err;
682682

683-
return phy_power_on(pcie->phy);
683+
err = phy_power_on(pcie->phy);
684+
if (err)
685+
phy_exit(pcie->phy);
686+
687+
return err;
684688
}
685689

686690
static int rcar_msi_alloc(struct rcar_msi *chip)
@@ -1165,7 +1169,7 @@ static int rcar_pcie_probe(struct platform_device *pdev)
11651169
if (rcar_pcie_hw_init(pcie)) {
11661170
dev_info(dev, "PCIe link down\n");
11671171
err = -ENODEV;
1168-
goto err_clk_disable;
1172+
goto err_phy_shutdown;
11691173
}
11701174

11711175
data = rcar_pci_read_reg(pcie, MACSR);
@@ -1177,7 +1181,7 @@ static int rcar_pcie_probe(struct platform_device *pdev)
11771181
dev_err(dev,
11781182
"failed to enable MSI support: %d\n",
11791183
err);
1180-
goto err_clk_disable;
1184+
goto err_phy_shutdown;
11811185
}
11821186
}
11831187

@@ -1191,6 +1195,12 @@ static int rcar_pcie_probe(struct platform_device *pdev)
11911195
if (IS_ENABLED(CONFIG_PCI_MSI))
11921196
rcar_pcie_teardown_msi(pcie);
11931197

1198+
err_phy_shutdown:
1199+
if (pcie->phy) {
1200+
phy_power_off(pcie->phy);
1201+
phy_exit(pcie->phy);
1202+
}
1203+
11941204
err_clk_disable:
11951205
clk_disable_unprepare(pcie->bus_clk);
11961206

‎drivers/pci/controller/pcie-xilinx-nwl.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ static int nwl_pcie_init_irq_domain(struct nwl_pcie *pcie)
559559
PCI_NUM_INTX,
560560
&legacy_domain_ops,
561561
pcie);
562-
562+
of_node_put(legacy_intc_node);
563563
if (!pcie->legacy_irq_domain) {
564564
dev_err(dev, "failed to create IRQ domain\n");
565565
return -ENOMEM;

‎drivers/pci/controller/pcie-xilinx.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,7 @@ static int xilinx_pcie_init_irq_domain(struct xilinx_pcie_port *port)
509509
port->leg_domain = irq_domain_add_linear(pcie_intc_node, PCI_NUM_INTX,
510510
&intx_domain_ops,
511511
port);
512+
of_node_put(pcie_intc_node);
512513
if (!port->leg_domain) {
513514
dev_err(dev, "Failed to get a INTx IRQ domain\n");
514515
return -ENODEV;

‎drivers/pci/endpoint/pci-epf-core.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,10 @@ EXPORT_SYMBOL_GPL(pci_epf_alloc_space);
145145
*/
146146
void pci_epf_unregister_driver(struct pci_epf_driver *driver)
147147
{
148-
struct config_group *group;
148+
struct config_group *group, *tmp;
149149

150150
mutex_lock(&pci_epf_mutex);
151-
list_for_each_entry(group, &driver->epf_group, group_entry)
151+
list_for_each_entry_safe(group, tmp, &driver->epf_group, group_entry)
152152
pci_ep_cfs_remove_epf_group(group);
153153
list_del(&driver->epf_group);
154154
mutex_unlock(&pci_epf_mutex);

‎drivers/pci/iov.c‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,22 @@ void pci_iov_release(struct pci_dev *dev)
574574
sriov_release(dev);
575575
}
576576

577+
/**
578+
* pci_iov_remove - clean up SR-IOV state after PF driver is detached
579+
* @dev: the PCI device
580+
*/
581+
void pci_iov_remove(struct pci_dev *dev)
582+
{
583+
struct pci_sriov *iov = dev->sriov;
584+
585+
if (!dev->is_physfn)
586+
return;
587+
588+
iov->driver_max_VFs = iov->total_VFs;
589+
if (iov->num_VFs)
590+
pci_warn(dev, "driver left SR-IOV enabled after remove\n");
591+
}
592+
577593
/**
578594
* pci_iov_update_resource - update a VF BAR
579595
* @dev: the PCI device

‎drivers/pci/pci-driver.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,7 @@ static int pci_device_remove(struct device *dev)
445445
}
446446
pcibios_free_irq(pci_dev);
447447
pci_dev->driver = NULL;
448+
pci_iov_remove(pci_dev);
448449
}
449450

450451
/* Undo the runtime PM settings in local_pci_probe() */

‎drivers/pci/pci.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ static inline void pci_restore_ats_state(struct pci_dev *dev)
311311
#ifdef CONFIG_PCI_IOV
312312
int pci_iov_init(struct pci_dev *dev);
313313
void pci_iov_release(struct pci_dev *dev);
314+
void pci_iov_remove(struct pci_dev *dev);
314315
void pci_iov_update_resource(struct pci_dev *dev, int resno);
315316
resource_size_t pci_sriov_resource_alignment(struct pci_dev *dev, int resno);
316317
void pci_restore_iov_state(struct pci_dev *dev);
@@ -323,6 +324,9 @@ static inline int pci_iov_init(struct pci_dev *dev)
323324
}
324325
static inline void pci_iov_release(struct pci_dev *dev)
325326

327+
{
328+
}
329+
static inline void pci_iov_remove(struct pci_dev *dev)
326330
{
327331
}
328332
static inline void pci_restore_iov_state(struct pci_dev *dev)

0 commit comments

Comments
 (0)