Commit 91b33022 authored by Gilles Chanteperdrix's avatar Gilles Chanteperdrix Committed by Philippe Gerum
Browse files

rtnet: transfer skb ownership when sending

to the device pool, to avoid crashes when a socket is destroyed while it
has buffers queued in the device transmit ring. This is a consequence of
commit 45474093, buffers from the socket
pool no longer prevent the socket from being destroyed.

At this chance, rename the device pool "rx_pool" to "dev_pool", as it is
now also used for transmission.
parent add91aef
......@@ -636,7 +636,8 @@ static int rtl8139_init_board (struct pci_dev *pdev,
*dev_out = NULL;
/* dev and rtdev->priv zeroed in alloc_etherdev */
rtdev=rt_alloc_etherdev(sizeof (struct rtl8139_private), rx_pool_size);
rtdev=rt_alloc_etherdev(sizeof (struct rtl8139_private),
rx_pool_size + NUM_TX_DESC);
if (rtdev==NULL) {
rtdm_printk (KERN_ERR PFX "%s: Unable to alloc new net device\n", pci_name(pdev));
return -ENOMEM;
......
......@@ -309,7 +309,7 @@ static int __init at91ether_probe(struct platform_device *pdev)
if (!regs)
return -ENOENT;
dev = rt_alloc_etherdev(sizeof(struct macb), MAX_RX_DESCR * 2);
dev = rt_alloc_etherdev(sizeof(struct macb), MAX_RX_DESCR * 2 + 2);
if (!dev)
return -ENOMEM;
......
......@@ -716,7 +716,7 @@ static int e1000_probe(struct pci_dev *pdev,
pci_set_master(pdev);
netdev = rt_alloc_etherdev(sizeof(struct e1000_adapter), 16);
netdev = rt_alloc_etherdev(sizeof(struct e1000_adapter), 48);
if (!netdev) {
err = -ENOMEM;
goto err_alloc_etherdev;
......
......@@ -3941,7 +3941,8 @@ static int e1000_probe(struct pci_dev *pdev,
goto err_alloc_etherdev;
err = -ENOMEM;
netdev = rt_alloc_etherdev(sizeof(struct e1000_adapter), RT_E1000E_NUM_RXD);
netdev = rt_alloc_etherdev(sizeof(*adapter),
2 * RT_E1000E_NUM_RXD + 256);
if (!netdev)
goto err_alloc_etherdev;
......
......@@ -670,7 +670,8 @@ static int speedo_found1(struct pci_dev *pdev,
return -1;
// *** RTnet ***
rtdev = rt_alloc_etherdev(sizeof(struct speedo_private), RX_RING_SIZE*2);
rtdev = rt_alloc_etherdev(sizeof(struct speedo_private),
RX_RING_SIZE * 2 + TX_RING_SIZE);
if (rtdev == NULL) {
printk(KERN_ERR "eepro100: Could not allocate ethernet device.\n");
pci_free_consistent(pdev, size, tx_ring_space, tx_ring_dma);
......
......@@ -340,7 +340,8 @@ static void eth1394_add_host (struct hpsb_host *host)
//******RTnet******
dev = rt_alloc_etherdev(sizeof (struct eth1394_priv), RX_RING_SIZE*2);
dev = rt_alloc_etherdev(sizeof (struct eth1394_priv),
RX_RING_SIZE * 2 + TX_RING_SIZE);
if (dev == NULL) {
ETH1394_PRINT_G (KERN_ERR, "Out of memory trying to allocate "
"etherdevice for IEEE 1394 device\n");
......
......@@ -974,7 +974,7 @@ static int vortex_probe1(struct pci_dev *pdev,
print_name = pdev ? pci_name(pdev) : "3c59x";
// *** RTnet ***
rtdev = rt_alloc_etherdev(sizeof(*vp), RX_RING_SIZE*2);
rtdev = rt_alloc_etherdev(sizeof(*vp), RX_RING_SIZE * 2 + TX_RING_SIZE);
retval = -ENOMEM;
if (!rtdev) {
printk (KERN_ERR PFX "unable to allocate etherdev, aborting\n");
......
......@@ -1075,7 +1075,8 @@ static int e1000_probe(struct pci_dev *pdev,
(sizeof(struct net_device_subqueue) *
E1000_MAX_TX_QUEUES), 16);
#else
netdev = rt_alloc_etherdev(sizeof(struct e1000_adapter), 16);
netdev = rt_alloc_etherdev(sizeof(struct e1000_adapter),
2 * E1000_DEFAULT_RXD + E1000_DEFAULT_TXD);
#endif
if (!netdev)
goto err_alloc_etherdev;
......
......@@ -1632,7 +1632,8 @@ static int fec_probe(struct platform_device *pdev)
return -EBUSY;
/* Init network device */
ndev = rt_alloc_etherdev(sizeof(struct fec_enet_private), rx_pool_size);
ndev = rt_alloc_etherdev(sizeof(struct fec_enet_private),
rx_pool_size + TX_RING_SIZE);
if (!ndev) {
ret = -ENOMEM;
goto failed_alloc_etherdev;
......
......@@ -1573,7 +1573,7 @@ static int __init macb_probe(struct platform_device *pdev)
}
err = -ENOMEM;
dev = rt_alloc_etherdev(sizeof(*bp), RX_RING_SIZE * 2);
dev = rt_alloc_etherdev(sizeof(*bp), RX_RING_SIZE * 2 + TX_RING_SIZE);
if (!dev)
goto err_out;
......
......@@ -1894,7 +1894,7 @@ mpc5xxx_fec_init(void)
if (!rx_pool_size)
rx_pool_size = MPC5xxx_FEC_RBD_NUM * 2;
dev = rt_alloc_etherdev(sizeof(*priv), rx_pool_size);
dev = rt_alloc_etherdev(sizeof(*priv), rx_pool_size + MPC5xxx_FEC_TBD_NUM);
if (!dev)
return -EIO;
rtdev_alloc_name(dev, "rteth%d");
......
......@@ -1613,7 +1613,7 @@ int __init fec_enet_init(void)
rx_pool_size = RX_RING_SIZE * 2;
rtdev = rt_alloc_etherdev(sizeof(struct fcc_enet_private),
rx_pool_size);
rx_pool_size + TX_RING_SIZE);
if (rtdev == NULL) {
printk(KERN_ERR "fcc_enet: Could not allocate ethernet device.\n");
return -1;
......
......@@ -719,7 +719,7 @@ int __init scc_enet_init(void)
if (!rx_pool_size)
rx_pool_size = RX_RING_SIZE * 2;
rtdev = rtdev_root = rt_alloc_etherdev(sizeof(struct scc_enet_private),
rx_pool_size);
rx_pool_size + TX_RING_SIZE);
if (rtdev == NULL) {
printk(KERN_ERR "enet: Could not allocate ethernet device.\n");
return -1;
......
......@@ -1869,7 +1869,7 @@ int __init fec_enet_init(void)
rx_pool_size = RX_RING_SIZE * 2;
rtdev = rtdev_root = rt_alloc_etherdev(sizeof(struct fec_enet_private),
rx_pool_size);
rx_pool_size + TX_RING_SIZE);
if (rtdev == NULL) {
printk(KERN_ERR "enet: Could not allocate ethernet device.\n");
return -1;
......
......@@ -778,7 +778,8 @@ static int natsemi_probe1 (struct pci_dev *pdev,
pci_set_master(pdev);
/*** RTnet ***/
dev = rt_alloc_etherdev(sizeof(struct netdev_private), RX_RING_SIZE*2);
dev = rt_alloc_etherdev(sizeof(struct netdev_private),
RX_RING_SIZE * 2 + TX_RING_SIZE);
if (dev == NULL) {
rtdm_printk(KERN_ERR "init_ethernet failed for card #%d\n", find_cnt);
goto err_out;
......
......@@ -638,7 +638,7 @@ static int pcnet32_probe1(unsigned long ioaddr, unsigned int irq_line, int share
}
/*** RTnet ***/
dev = rt_alloc_etherdev(0, RX_RING_SIZE*2);
dev = rt_alloc_etherdev(0, RX_RING_SIZE * 2 + TX_RING_SIZE);
if (dev == NULL)
return -ENOMEM;
rtdev_alloc_name(dev, "rteth%d");
......
......@@ -580,7 +580,8 @@ static int rtl8169_init_board ( struct pci_dev *pdev, struct rtnet_device **dev_
*dev_out = NULL;
/*** RTnet ***/
rtdev = rt_alloc_etherdev(sizeof(struct rtl8169_private), RX_RING_SIZE*2);
rtdev = rt_alloc_etherdev(sizeof(struct rtl8169_private),
RX_RING_SIZE * 2 + TX_RING_SIZE);
if (rtdev == NULL) {
printk (KERN_ERR PFX "unable to alloc new ethernet\n");
return -ENOMEM;
......
......@@ -1744,7 +1744,7 @@ int __init init_module(void)
printk(KERN_WARNING
CARDNAME": You shouldn't use auto-probing with insmod!\n" );
devSMC91111 = rt_alloc_etherdev(sizeof(struct smc_local), 4*2);
devSMC91111 = rt_alloc_etherdev(sizeof(struct smc_local), 4 * 2 + 1);
if (devSMC91111 == NULL) {
printk (KERN_ERR "init_ethernet failed\n");
return -ENODEV;
......
......@@ -950,7 +950,8 @@ static int tulip_init_one (struct pci_dev *pdev,
irq = pdev->irq;
/* alloc_etherdev ensures aligned and zeroed private structures */
rtdev = /*RTnet*/rt_alloc_etherdev (sizeof (*tp), RX_RING_SIZE*2);
rtdev = /*RTnet*/rt_alloc_etherdev (sizeof (*tp),
RX_RING_SIZE * 2 + TX_RING_SIZE);
if (!rtdev) {
printk(KERN_ERR PFX "ether device alloc failed, aborting\n");
return -ENOMEM;
......
......@@ -681,7 +681,8 @@ static int via_rhine_init_one (struct pci_dev *pdev,
pci_set_master (pdev);
/*** RTnet ***/
dev = rt_alloc_etherdev(sizeof(struct netdev_private), RX_RING_SIZE*2);
dev = rt_alloc_etherdev(sizeof(struct netdev_private),
RX_RING_SIZE * 2 + TX_RING_SIZE);
if (dev == NULL) {
printk (KERN_ERR "init_ethernet failed for card #%d\n", card_idx);
goto err_out;
......
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