forked from Minki/linux
[PATCH] skge: handle out of memory on MTU size changes
Changing the MTU size causes the receiver to have to reallocate buffers. If this allocation fails, then we need to return an error, and take the device offline. It can then be brought back up or reconfigured for a smaller MTU. Signed-off-by: Stephen Hemminger <shemminger@osdl.org> Signed-off-by: Jeff Garzik <jgarzik@pobox.com>
This commit is contained in:
parent
e8df855460
commit
7731a4ea1b
@ -2192,6 +2192,7 @@ static int skge_up(struct net_device *dev)
|
|||||||
kfree(skge->rx_ring.start);
|
kfree(skge->rx_ring.start);
|
||||||
free_pci_mem:
|
free_pci_mem:
|
||||||
pci_free_consistent(hw->pdev, skge->mem_size, skge->mem, skge->dma);
|
pci_free_consistent(hw->pdev, skge->mem_size, skge->mem, skge->dma);
|
||||||
|
skge->mem = NULL;
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
@ -2202,6 +2203,9 @@ static int skge_down(struct net_device *dev)
|
|||||||
struct skge_hw *hw = skge->hw;
|
struct skge_hw *hw = skge->hw;
|
||||||
int port = skge->port;
|
int port = skge->port;
|
||||||
|
|
||||||
|
if (skge->mem == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
if (netif_msg_ifdown(skge))
|
if (netif_msg_ifdown(skge))
|
||||||
printk(KERN_INFO PFX "%s: disabling interface\n", dev->name);
|
printk(KERN_INFO PFX "%s: disabling interface\n", dev->name);
|
||||||
|
|
||||||
@ -2258,6 +2262,7 @@ static int skge_down(struct net_device *dev)
|
|||||||
kfree(skge->rx_ring.start);
|
kfree(skge->rx_ring.start);
|
||||||
kfree(skge->tx_ring.start);
|
kfree(skge->tx_ring.start);
|
||||||
pci_free_consistent(hw->pdev, skge->mem_size, skge->mem, skge->dma);
|
pci_free_consistent(hw->pdev, skge->mem_size, skge->mem, skge->dma);
|
||||||
|
skge->mem = NULL;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2418,18 +2423,23 @@ static void skge_tx_timeout(struct net_device *dev)
|
|||||||
|
|
||||||
static int skge_change_mtu(struct net_device *dev, int new_mtu)
|
static int skge_change_mtu(struct net_device *dev, int new_mtu)
|
||||||
{
|
{
|
||||||
int err = 0;
|
int err;
|
||||||
int running = netif_running(dev);
|
|
||||||
|
|
||||||
if (new_mtu < ETH_ZLEN || new_mtu > ETH_JUMBO_MTU)
|
if (new_mtu < ETH_ZLEN || new_mtu > ETH_JUMBO_MTU)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
if (!netif_running(dev)) {
|
||||||
|
dev->mtu = new_mtu;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
skge_down(dev);
|
||||||
|
|
||||||
if (running)
|
|
||||||
skge_down(dev);
|
|
||||||
dev->mtu = new_mtu;
|
dev->mtu = new_mtu;
|
||||||
if (running)
|
|
||||||
skge_up(dev);
|
err = skge_up(dev);
|
||||||
|
if (err)
|
||||||
|
dev_close(dev);
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user