Commit fabc51a6 authored by Kulikov Vasiliy's avatar Kulikov Vasiliy Committed by David S. Miller

fec_mpc52xx: fix error path

Error path in mpc52xx_fec_probe() is broken.
We must free everything that we've allocated.
Signed-off-by: default avatarKulikov Vasiliy <segooon@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 7cc36f6f
...@@ -875,17 +875,21 @@ mpc52xx_fec_probe(struct of_device *op, const struct of_device_id *match) ...@@ -875,17 +875,21 @@ mpc52xx_fec_probe(struct of_device *op, const struct of_device_id *match)
if (rv) { if (rv) {
printk(KERN_ERR DRIVER_NAME ": " printk(KERN_ERR DRIVER_NAME ": "
"Error while parsing device node resource\n" ); "Error while parsing device node resource\n" );
return rv; goto err_netdev;
} }
if ((mem.end - mem.start + 1) < sizeof(struct mpc52xx_fec)) { if ((mem.end - mem.start + 1) < sizeof(struct mpc52xx_fec)) {
printk(KERN_ERR DRIVER_NAME printk(KERN_ERR DRIVER_NAME
" - invalid resource size (%lx < %x), check mpc52xx_devices.c\n", " - invalid resource size (%lx < %x), check mpc52xx_devices.c\n",
(unsigned long)(mem.end - mem.start + 1), sizeof(struct mpc52xx_fec)); (unsigned long)(mem.end - mem.start + 1), sizeof(struct mpc52xx_fec));
return -EINVAL; rv = -EINVAL;
goto err_netdev;
} }
if (!request_mem_region(mem.start, sizeof(struct mpc52xx_fec), DRIVER_NAME)) if (!request_mem_region(mem.start, sizeof(struct mpc52xx_fec),
return -EBUSY; DRIVER_NAME)) {
rv = -EBUSY;
goto err_netdev;
}
/* Init ether ndev with what we have */ /* Init ether ndev with what we have */
ndev->netdev_ops = &mpc52xx_fec_netdev_ops; 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,7 +905,7 @@ mpc52xx_fec_probe(struct of_device *op, const struct of_device_id *match)
if (!priv->fec) { if (!priv->fec) {
rv = -ENOMEM; rv = -ENOMEM;
goto probe_error; goto err_mem_region;
} }
/* Bestcomm init */ /* Bestcomm init */
...@@ -914,7 +918,7 @@ mpc52xx_fec_probe(struct of_device *op, const struct of_device_id *match) ...@@ -914,7 +918,7 @@ mpc52xx_fec_probe(struct of_device *op, const struct of_device_id *match)
if (!priv->rx_dmatsk || !priv->tx_dmatsk) { if (!priv->rx_dmatsk || !priv->tx_dmatsk) {
printk(KERN_ERR DRIVER_NAME ": Can not init SDMA tasks\n" ); printk(KERN_ERR DRIVER_NAME ": Can not init SDMA tasks\n" );
rv = -ENOMEM; rv = -ENOMEM;
goto probe_error; goto err_rx_tx_dmatsk;
} }
/* Get the IRQ we need one by one */ /* 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,33 +970,25 @@ mpc52xx_fec_probe(struct of_device *op, const struct of_device_id *match)
rv = register_netdev(ndev); rv = register_netdev(ndev);
if (rv < 0) if (rv < 0)
goto probe_error; goto err_node;
/* We're done ! */ /* We're done ! */
dev_set_drvdata(&op->dev, ndev); dev_set_drvdata(&op->dev, ndev);
return 0; return 0;
err_node:
/* Error handling - free everything that might be allocated */ of_node_put(priv->phy_node);
probe_error:
if (priv->phy_node)
of_node_put(priv->phy_node);
priv->phy_node = NULL;
irq_dispose_mapping(ndev->irq); irq_dispose_mapping(ndev->irq);
err_rx_tx_dmatsk:
if (priv->rx_dmatsk) if (priv->rx_dmatsk)
bcom_fec_rx_release(priv->rx_dmatsk); bcom_fec_rx_release(priv->rx_dmatsk);
if (priv->tx_dmatsk) if (priv->tx_dmatsk)
bcom_fec_tx_release(priv->tx_dmatsk); bcom_fec_tx_release(priv->tx_dmatsk);
iounmap(priv->fec);
if (priv->fec) err_mem_region:
iounmap(priv->fec);
release_mem_region(mem.start, sizeof(struct mpc52xx_fec)); release_mem_region(mem.start, sizeof(struct mpc52xx_fec));
err_netdev:
free_netdev(ndev); free_netdev(ndev);
return rv; return rv;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment