aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/fec_mpc52xx.c
diff options
context:
space:
mode:
authorKulikov Vasiliy <segooon@gmail.com>2010-07-09 02:44:26 -0400
committerDavid S. Miller <davem@davemloft.net>2010-07-09 02:44:26 -0400
commitfabc51a640b35a771b6c75d2186193fdaf25cf56 (patch)
tree7437ca89bfb52f27a3dd25b93469b3c065de116d /drivers/net/fec_mpc52xx.c
parent7cc36f6f7116918c8a8990a0f23f62d2288a81bf (diff)
fec_mpc52xx: fix error path
Error path in mpc52xx_fec_probe() is broken. We must free everything that we've allocated. Signed-off-by: Kulikov Vasiliy <segooon@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/fec_mpc52xx.c')
-rw-r--r--drivers/net/fec_mpc52xx.c38
1 files changed, 17 insertions, 21 deletions
diff --git a/drivers/net/fec_mpc52xx.c b/drivers/net/fec_mpc52xx.c
index 25e6cc6840b1..5f8346369b80 100644
--- a/drivers/net/fec_mpc52xx.c
+++ b/drivers/net/fec_mpc52xx.c
@@ -875,17 +875,21 @@ mpc52xx_fec_probe(struct of_device *op, const struct of_device_id *match)
875 if (rv) { 875 if (rv) {
876 printk(KERN_ERR DRIVER_NAME ": " 876 printk(KERN_ERR DRIVER_NAME ": "
877 "Error while parsing device node resource\n" ); 877 "Error while parsing device node resource\n" );
878 return rv; 878 goto err_netdev;
879 } 879 }
880 if ((mem.end - mem.start + 1) < sizeof(struct mpc52xx_fec)) { 880 if ((mem.end - mem.start + 1) < sizeof(struct mpc52xx_fec)) {
881 printk(KERN_ERR DRIVER_NAME 881 printk(KERN_ERR DRIVER_NAME
882 " - invalid resource size (%lx < %x), check mpc52xx_devices.c\n", 882 " - invalid resource size (%lx < %x), check mpc52xx_devices.c\n",
883 (unsigned long)(mem.end - mem.start + 1), sizeof(struct mpc52xx_fec)); 883 (unsigned long)(mem.end - mem.start + 1), sizeof(struct mpc52xx_fec));
884 return -EINVAL; 884 rv = -EINVAL;
885 goto err_netdev;
885 } 886 }
886 887
887 if (!request_mem_region(mem.start, sizeof(struct mpc52xx_fec), DRIVER_NAME)) 888 if (!request_mem_region(mem.start, sizeof(struct mpc52xx_fec),
888 return -EBUSY; 889 DRIVER_NAME)) {
890 rv = -EBUSY;
891 goto err_netdev;
892 }
889 893
890 /* Init ether ndev with what we have */ 894 /* Init ether ndev with what we have */
891 ndev->netdev_ops = &mpc52xx_fec_netdev_ops; 895 ndev->netdev_ops = &mpc52xx_fec_netdev_ops;
@@ -901,7 +905,7 @@ mpc52xx_fec_probe(struct of_device *op, const struct of_device_id *match)
901 905
902 if (!priv->fec) { 906 if (!priv->fec) {
903 rv = -ENOMEM; 907 rv = -ENOMEM;
904 goto probe_error; 908 goto err_mem_region;
905 } 909 }
906 910
907 /* Bestcomm init */ 911 /* Bestcomm init */
@@ -914,7 +918,7 @@ mpc52xx_fec_probe(struct of_device *op, const struct of_device_id *match)
914 if (!priv->rx_dmatsk || !priv->tx_dmatsk) { 918 if (!priv->rx_dmatsk || !priv->tx_dmatsk) {
915 printk(KERN_ERR DRIVER_NAME ": Can not init SDMA tasks\n" ); 919 printk(KERN_ERR DRIVER_NAME ": Can not init SDMA tasks\n" );
916 rv = -ENOMEM; 920 rv = -ENOMEM;
917 goto probe_error; 921 goto err_rx_tx_dmatsk;
918 } 922 }
919 923
920 /* Get the IRQ we need one by one */ 924 /* Get the IRQ we need one by one */
@@ -966,33 +970,25 @@ mpc52xx_fec_probe(struct of_device *op, const struct of_device_id *match)
966 970
967 rv = register_netdev(ndev); 971 rv = register_netdev(ndev);
968 if (rv < 0) 972 if (rv < 0)
969 goto probe_error; 973 goto err_node;
970 974
971 /* We're done ! */ 975 /* We're done ! */
972 dev_set_drvdata(&op->dev, ndev); 976 dev_set_drvdata(&op->dev, ndev);
973 977
974 return 0; 978 return 0;
975 979
976 980err_node:
977 /* Error handling - free everything that might be allocated */ 981 of_node_put(priv->phy_node);
978probe_error:
979
980 if (priv->phy_node)
981 of_node_put(priv->phy_node);
982 priv->phy_node = NULL;
983
984 irq_dispose_mapping(ndev->irq); 982 irq_dispose_mapping(ndev->irq);
985 983err_rx_tx_dmatsk:
986 if (priv->rx_dmatsk) 984 if (priv->rx_dmatsk)
987 bcom_fec_rx_release(priv->rx_dmatsk); 985 bcom_fec_rx_release(priv->rx_dmatsk);
988 if (priv->tx_dmatsk) 986 if (priv->tx_dmatsk)
989 bcom_fec_tx_release(priv->tx_dmatsk); 987 bcom_fec_tx_release(priv->tx_dmatsk);
990 988 iounmap(priv->fec);
991 if (priv->fec) 989err_mem_region:
992 iounmap(priv->fec);
993
994 release_mem_region(mem.start, sizeof(struct mpc52xx_fec)); 990 release_mem_region(mem.start, sizeof(struct mpc52xx_fec));
995 991err_netdev:
996 free_netdev(ndev); 992 free_netdev(ndev);
997 993
998 return rv; 994 return rv;