Commit de041bc6 authored by Florian Fainelli's avatar Florian Fainelli Committed by Ben Hutchings

net: ethoc: Fix early error paths

commit 386512d1 upstream.

In case any operation fails before we can successfully go the point
where we would register a MDIO bus, we would be going to an error label
which involves unregistering then freeing this yet to be created MDIO
bus. Update all error paths to go to label free which is the only one
valid until either the clock is enabled, or the MDIO bus is allocated
and registered. This fixes kernel oops observed while trying to
dereference the MDIO bus structure which is not yet allocated.

Fixes: a1702857 ("net: Add support for the OpenCores 10/100 Mbps Ethernet MAC.")
Signed-off-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
parent ed287163
...@@ -1080,7 +1080,7 @@ static int ethoc_probe(struct platform_device *pdev) ...@@ -1080,7 +1080,7 @@ static int ethoc_probe(struct platform_device *pdev)
if (!priv->iobase) { if (!priv->iobase) {
dev_err(&pdev->dev, "cannot remap I/O memory space\n"); dev_err(&pdev->dev, "cannot remap I/O memory space\n");
ret = -ENXIO; ret = -ENXIO;
goto error; goto free;
} }
if (netdev->mem_end) { if (netdev->mem_end) {
...@@ -1089,7 +1089,7 @@ static int ethoc_probe(struct platform_device *pdev) ...@@ -1089,7 +1089,7 @@ static int ethoc_probe(struct platform_device *pdev)
if (!priv->membase) { if (!priv->membase) {
dev_err(&pdev->dev, "cannot remap memory space\n"); dev_err(&pdev->dev, "cannot remap memory space\n");
ret = -ENXIO; ret = -ENXIO;
goto error; goto free;
} }
} else { } else {
/* Allocate buffer memory */ /* Allocate buffer memory */
...@@ -1100,7 +1100,7 @@ static int ethoc_probe(struct platform_device *pdev) ...@@ -1100,7 +1100,7 @@ static int ethoc_probe(struct platform_device *pdev)
dev_err(&pdev->dev, "cannot allocate %dB buffer\n", dev_err(&pdev->dev, "cannot allocate %dB buffer\n",
buffer_size); buffer_size);
ret = -ENOMEM; ret = -ENOMEM;
goto error; goto free;
} }
netdev->mem_end = netdev->mem_start + buffer_size; netdev->mem_end = netdev->mem_start + buffer_size;
priv->dma_alloc = buffer_size; priv->dma_alloc = buffer_size;
...@@ -1111,7 +1111,7 @@ static int ethoc_probe(struct platform_device *pdev) ...@@ -1111,7 +1111,7 @@ static int ethoc_probe(struct platform_device *pdev)
128, (netdev->mem_end - netdev->mem_start + 1) / ETHOC_BUFSIZ); 128, (netdev->mem_end - netdev->mem_start + 1) / ETHOC_BUFSIZ);
if (num_bd < 4) { if (num_bd < 4) {
ret = -ENODEV; ret = -ENODEV;
goto error; goto free;
} }
priv->num_bd = num_bd; priv->num_bd = num_bd;
/* num_tx must be a power of two */ /* num_tx must be a power of two */
...@@ -1124,7 +1124,7 @@ static int ethoc_probe(struct platform_device *pdev) ...@@ -1124,7 +1124,7 @@ static int ethoc_probe(struct platform_device *pdev)
priv->vma = devm_kzalloc(&pdev->dev, num_bd*sizeof(void *), GFP_KERNEL); priv->vma = devm_kzalloc(&pdev->dev, num_bd*sizeof(void *), GFP_KERNEL);
if (!priv->vma) { if (!priv->vma) {
ret = -ENOMEM; ret = -ENOMEM;
goto error; goto free;
} }
/* Allow the platform setup code to pass in a MAC address. */ /* Allow the platform setup code to pass in a MAC address. */
......
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