Skip to content

Commit 7f94d04

Browse files
Yang YingliangPaolo Abeni
authored andcommitted
stmmac: dwmac-loongson: fix missing of_node_put() while module exiting
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: 2ae3411 ("stmmac: dwmac-loongson: fix invalid mdio_node") Signed-off-by: Yang Yingliang <yangyingliang@huawei.com> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
1 parent fe5b3ce commit 7f94d04

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,20 +75,24 @@ static int loongson_dwmac_probe(struct pci_dev *pdev, const struct pci_device_id
7575
plat->mdio_bus_data = devm_kzalloc(&pdev->dev,
7676
sizeof(*plat->mdio_bus_data),
7777
GFP_KERNEL);
78-
if (!plat->mdio_bus_data)
79-
return -ENOMEM;
78+
if (!plat->mdio_bus_data) {
79+
ret = -ENOMEM;
80+
goto err_put_node;
81+
}
8082
plat->mdio_bus_data->needs_reset = true;
8183
}
8284

8385
plat->dma_cfg = devm_kzalloc(&pdev->dev, sizeof(*plat->dma_cfg), GFP_KERNEL);
84-
if (!plat->dma_cfg)
85-
return -ENOMEM;
86+
if (!plat->dma_cfg) {
87+
ret = -ENOMEM;
88+
goto err_put_node;
89+
}
8690

8791
/* Enable pci device */
8892
ret = pci_enable_device(pdev);
8993
if (ret) {
9094
dev_err(&pdev->dev, "%s: ERROR: failed to enable device\n", __func__);
91-
return ret;
95+
goto err_put_node;
9296
}
9397

9498
/* Get the base address of device */
@@ -152,13 +156,18 @@ static int loongson_dwmac_probe(struct pci_dev *pdev, const struct pci_device_id
152156
pci_disable_msi(pdev);
153157
err_disable_device:
154158
pci_disable_device(pdev);
159+
err_put_node:
160+
of_node_put(plat->mdio_node);
155161
return ret;
156162
}
157163

158164
static void loongson_dwmac_remove(struct pci_dev *pdev)
159165
{
166+
struct net_device *ndev = dev_get_drvdata(&pdev->dev);
167+
struct stmmac_priv *priv = netdev_priv(ndev);
160168
int i;
161169

170+
of_node_put(priv->plat->mdio_node);
162171
stmmac_dvr_remove(&pdev->dev);
163172

164173
for (i = 0; i < PCI_STD_NUM_BARS; i++) {

0 commit comments

Comments
 (0)