Skip to content

Commit

Permalink
Merge branch 'stmmac-dwmac-loongson-fixes-three-leaks'
Browse files Browse the repository at this point in the history
Yang Yingliang says:

====================
stmmac: dwmac-loongson: fixes three leaks

patch android-rpi#2 fixes missing pci_disable_device() in the error path in probe()
patch android-rpi#1 and pach android-rpi#3 fix missing pci_disable_msi() and of_node_put() in
error and remove() path.
====================

Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Abeni <[email protected]>
  • Loading branch information
Paolo Abeni committed Nov 10, 2022
2 parents c6092ea + 7f94d04 commit 63eec6f
Showing 1 changed file with 31 additions and 8 deletions.
39 changes: 31 additions & 8 deletions drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,20 +75,24 @@ static int loongson_dwmac_probe(struct pci_dev *pdev, const struct pci_device_id
plat->mdio_bus_data = devm_kzalloc(&pdev->dev,
sizeof(*plat->mdio_bus_data),
GFP_KERNEL);
if (!plat->mdio_bus_data)
return -ENOMEM;
if (!plat->mdio_bus_data) {
ret = -ENOMEM;
goto err_put_node;
}
plat->mdio_bus_data->needs_reset = true;
}

plat->dma_cfg = devm_kzalloc(&pdev->dev, sizeof(*plat->dma_cfg), GFP_KERNEL);
if (!plat->dma_cfg)
return -ENOMEM;
if (!plat->dma_cfg) {
ret = -ENOMEM;
goto err_put_node;
}

/* Enable pci device */
ret = pci_enable_device(pdev);
if (ret) {
dev_err(&pdev->dev, "%s: ERROR: failed to enable device\n", __func__);
return ret;
goto err_put_node;
}

/* Get the base address of device */
Expand All @@ -97,7 +101,7 @@ static int loongson_dwmac_probe(struct pci_dev *pdev, const struct pci_device_id
continue;
ret = pcim_iomap_regions(pdev, BIT(0), pci_name(pdev));
if (ret)
return ret;
goto err_disable_device;
break;
}

Expand All @@ -108,7 +112,8 @@ static int loongson_dwmac_probe(struct pci_dev *pdev, const struct pci_device_id
phy_mode = device_get_phy_mode(&pdev->dev);
if (phy_mode < 0) {
dev_err(&pdev->dev, "phy_mode not found\n");
return phy_mode;
ret = phy_mode;
goto err_disable_device;
}

plat->phy_interface = phy_mode;
Expand All @@ -125,6 +130,7 @@ static int loongson_dwmac_probe(struct pci_dev *pdev, const struct pci_device_id
if (res.irq < 0) {
dev_err(&pdev->dev, "IRQ macirq not found\n");
ret = -ENODEV;
goto err_disable_msi;
}

res.wol_irq = of_irq_get_byname(np, "eth_wake_irq");
Expand All @@ -137,15 +143,31 @@ static int loongson_dwmac_probe(struct pci_dev *pdev, const struct pci_device_id
if (res.lpi_irq < 0) {
dev_err(&pdev->dev, "IRQ eth_lpi not found\n");
ret = -ENODEV;
goto err_disable_msi;
}

return stmmac_dvr_probe(&pdev->dev, plat, &res);
ret = stmmac_dvr_probe(&pdev->dev, plat, &res);
if (ret)
goto err_disable_msi;

return ret;

err_disable_msi:
pci_disable_msi(pdev);
err_disable_device:
pci_disable_device(pdev);
err_put_node:
of_node_put(plat->mdio_node);
return ret;
}

static void loongson_dwmac_remove(struct pci_dev *pdev)
{
struct net_device *ndev = dev_get_drvdata(&pdev->dev);
struct stmmac_priv *priv = netdev_priv(ndev);
int i;

of_node_put(priv->plat->mdio_node);
stmmac_dvr_remove(&pdev->dev);

for (i = 0; i < PCI_STD_NUM_BARS; i++) {
Expand All @@ -155,6 +177,7 @@ static void loongson_dwmac_remove(struct pci_dev *pdev)
break;
}

pci_disable_msi(pdev);
pci_disable_device(pdev);
}

Expand Down

0 comments on commit 63eec6f

Please sign in to comment.