Skip to content

Commit 796bec1

Browse files
mminddavem330
authored andcommitted
arc_emac: fix probe error path
The probe function at the moment only frees the netdev but does not disconnect the phy or removes the mdio bus it registered. Signed-off-by: Heiko Stuebner <heiko@sntech.de> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 30313a3 commit 796bec1

1 file changed

Lines changed: 14 additions & 9 deletions

File tree

‎drivers/net/ethernet/arc/emac_main.c‎

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,7 @@ static int arc_emac_probe(struct platform_device *pdev)
683683
priv->regs = devm_ioremap_resource(&pdev->dev, &res_regs);
684684
if (IS_ERR(priv->regs)) {
685685
err = PTR_ERR(priv->regs);
686-
goto out;
686+
goto out_netdev;
687687
}
688688
dev_dbg(&pdev->dev, "Registers base address is 0x%p\n", priv->regs);
689689

@@ -693,7 +693,7 @@ static int arc_emac_probe(struct platform_device *pdev)
693693
if (!(id == 0x0005fd02 || id == 0x0007fd02)) {
694694
dev_err(&pdev->dev, "ARC EMAC not detected, id=0x%x\n", id);
695695
err = -ENODEV;
696-
goto out;
696+
goto out_netdev;
697697
}
698698
dev_info(&pdev->dev, "ARC EMAC detected with id: 0x%x\n", id);
699699

@@ -708,7 +708,7 @@ static int arc_emac_probe(struct platform_device *pdev)
708708
ndev->name, ndev);
709709
if (err) {
710710
dev_err(&pdev->dev, "could not allocate IRQ\n");
711-
goto out;
711+
goto out_netdev;
712712
}
713713

714714
/* Get MAC address from device tree */
@@ -729,7 +729,7 @@ static int arc_emac_probe(struct platform_device *pdev)
729729
if (!priv->rxbd) {
730730
dev_err(&pdev->dev, "failed to allocate data buffers\n");
731731
err = -ENOMEM;
732-
goto out;
732+
goto out_netdev;
733733
}
734734

735735
priv->txbd = priv->rxbd + RX_BD_NUM;
@@ -741,15 +741,15 @@ static int arc_emac_probe(struct platform_device *pdev)
741741
err = arc_mdio_probe(pdev, priv);
742742
if (err) {
743743
dev_err(&pdev->dev, "failed to probe MII bus\n");
744-
goto out;
744+
goto out_netdev;
745745
}
746746

747747
priv->phy_dev = of_phy_connect(ndev, phy_node, arc_emac_adjust_link, 0,
748748
PHY_INTERFACE_MODE_MII);
749749
if (!priv->phy_dev) {
750750
dev_err(&pdev->dev, "of_phy_connect() failed\n");
751751
err = -ENODEV;
752-
goto out;
752+
goto out_mdio;
753753
}
754754

755755
dev_info(&pdev->dev, "connected to %s phy with id 0x%x\n",
@@ -759,14 +759,19 @@ static int arc_emac_probe(struct platform_device *pdev)
759759

760760
err = register_netdev(ndev);
761761
if (err) {
762-
netif_napi_del(&priv->napi);
763762
dev_err(&pdev->dev, "failed to register network device\n");
764-
goto out;
763+
goto out_netif_api;
765764
}
766765

767766
return 0;
768767

769-
out:
768+
out_netif_api:
769+
netif_napi_del(&priv->napi);
770+
phy_disconnect(priv->phy_dev);
771+
priv->phy_dev = NULL;
772+
out_mdio:
773+
arc_mdio_remove(priv);
774+
out_netdev:
770775
free_netdev(ndev);
771776
return err;
772777
}

0 commit comments

Comments
 (0)