Commit ea43f860 authored by David S. Miller's avatar David S. Miller

Merge branch 'ethoc-fixes'

Florian Fainelli says:

====================
net: ethoc: Error path and transmit fixes

This patch series contains two patches for the ethoc driver while testing on a
TS-7300 board where ethoc is provided by an on-board FPGA.

First patch was cooked after chasing crashes with invalid resources passed to
the driver.

Second patch was cooked after seeing that an interface configured with IP
192.168.2.2 was sending ARP packets for 192.168.0.0, no wonder why it could not
work.

I don't have access to any other platform using an ethoc interface so
it could be good to some testing on Xtensa for instance.

Changes in v3:

- corrected the error path if skb_put_padto() fails, thanks to Max
  for spotting this!

Changes in v2:

- fixed the first commit message
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 136ab0d0 ee6c21b9
...@@ -860,6 +860,11 @@ static netdev_tx_t ethoc_start_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -860,6 +860,11 @@ static netdev_tx_t ethoc_start_xmit(struct sk_buff *skb, struct net_device *dev)
unsigned int entry; unsigned int entry;
void *dest; void *dest;
if (skb_put_padto(skb, ETHOC_ZLEN)) {
dev->stats.tx_errors++;
goto out_no_free;
}
if (unlikely(skb->len > ETHOC_BUFSIZ)) { if (unlikely(skb->len > ETHOC_BUFSIZ)) {
dev->stats.tx_errors++; dev->stats.tx_errors++;
goto out; goto out;
...@@ -894,6 +899,7 @@ static netdev_tx_t ethoc_start_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -894,6 +899,7 @@ static netdev_tx_t ethoc_start_xmit(struct sk_buff *skb, struct net_device *dev)
skb_tx_timestamp(skb); skb_tx_timestamp(skb);
out: out:
dev_kfree_skb(skb); dev_kfree_skb(skb);
out_no_free:
return NETDEV_TX_OK; return NETDEV_TX_OK;
} }
...@@ -1086,7 +1092,7 @@ static int ethoc_probe(struct platform_device *pdev) ...@@ -1086,7 +1092,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) {
...@@ -1095,7 +1101,7 @@ static int ethoc_probe(struct platform_device *pdev) ...@@ -1095,7 +1101,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 */
...@@ -1106,7 +1112,7 @@ static int ethoc_probe(struct platform_device *pdev) ...@@ -1106,7 +1112,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;
...@@ -1120,7 +1126,7 @@ static int ethoc_probe(struct platform_device *pdev) ...@@ -1120,7 +1126,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 */
...@@ -1133,7 +1139,7 @@ static int ethoc_probe(struct platform_device *pdev) ...@@ -1133,7 +1139,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