mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-07 15:01:44 +00:00
stmmac: dwmac-loongson: fix missing of_node_put() while module exiting
[ Upstream commit7f94d0498f
] The node returned by of_get_child_by_name() with refcount decremented, of_node_put() needs be called when finish using it. So add it in the error path in loongson_dwmac_probe() and in loongson_dwmac_remove(). Fixes:2ae34111fe
("stmmac: dwmac-loongson: fix invalid mdio_node") Signed-off-by: Yang Yingliang <yangyingliang@huawei.com> Signed-off-by: Paolo Abeni <pabeni@redhat.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
3ecc16b2d7
commit
3b872d5fdd
1 changed files with 14 additions and 5 deletions
|
@ -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,
|
plat->mdio_bus_data = devm_kzalloc(&pdev->dev,
|
||||||
sizeof(*plat->mdio_bus_data),
|
sizeof(*plat->mdio_bus_data),
|
||||||
GFP_KERNEL);
|
GFP_KERNEL);
|
||||||
if (!plat->mdio_bus_data)
|
if (!plat->mdio_bus_data) {
|
||||||
return -ENOMEM;
|
ret = -ENOMEM;
|
||||||
|
goto err_put_node;
|
||||||
|
}
|
||||||
plat->mdio_bus_data->needs_reset = true;
|
plat->mdio_bus_data->needs_reset = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
plat->dma_cfg = devm_kzalloc(&pdev->dev, sizeof(*plat->dma_cfg), GFP_KERNEL);
|
plat->dma_cfg = devm_kzalloc(&pdev->dev, sizeof(*plat->dma_cfg), GFP_KERNEL);
|
||||||
if (!plat->dma_cfg)
|
if (!plat->dma_cfg) {
|
||||||
return -ENOMEM;
|
ret = -ENOMEM;
|
||||||
|
goto err_put_node;
|
||||||
|
}
|
||||||
|
|
||||||
/* Enable pci device */
|
/* Enable pci device */
|
||||||
ret = pci_enable_device(pdev);
|
ret = pci_enable_device(pdev);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(&pdev->dev, "%s: ERROR: failed to enable device\n", __func__);
|
dev_err(&pdev->dev, "%s: ERROR: failed to enable device\n", __func__);
|
||||||
return ret;
|
goto err_put_node;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get the base address of device */
|
/* Get the base address of device */
|
||||||
|
@ -152,13 +156,18 @@ err_disable_msi:
|
||||||
pci_disable_msi(pdev);
|
pci_disable_msi(pdev);
|
||||||
err_disable_device:
|
err_disable_device:
|
||||||
pci_disable_device(pdev);
|
pci_disable_device(pdev);
|
||||||
|
err_put_node:
|
||||||
|
of_node_put(plat->mdio_node);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void loongson_dwmac_remove(struct pci_dev *pdev)
|
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;
|
int i;
|
||||||
|
|
||||||
|
of_node_put(priv->plat->mdio_node);
|
||||||
stmmac_dvr_remove(&pdev->dev);
|
stmmac_dvr_remove(&pdev->dev);
|
||||||
|
|
||||||
for (i = 0; i < PCI_STD_NUM_BARS; i++) {
|
for (i = 0; i < PCI_STD_NUM_BARS; i++) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue