Module: xenomai-3
Branch: master
Commit: 91b3302284fdb1e4140bb4313694b64d2e1dfd2b
URL:    
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=91b3302284fdb1e4140bb4313694b64d2e1dfd2b

Author: Gilles Chanteperdrix <gilles.chanteperd...@xenomai.org>
Date:   Tue Oct 13 21:14:10 2015 +0200

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 45474093d65bfa43968815520059dd530b4d9b78, 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.

---

 kernel/drivers/net/drivers/8139too.c               |    3 +-
 kernel/drivers/net/drivers/at91_ether.c            |    2 +-
 kernel/drivers/net/drivers/e1000/e1000_main.c      |    2 +-
 kernel/drivers/net/drivers/e1000e/netdev.c         |    3 +-
 kernel/drivers/net/drivers/eepro100.c              |    3 +-
 kernel/drivers/net/drivers/eth1394.c               |    3 +-
 kernel/drivers/net/drivers/experimental/3c59x.c    |    2 +-
 .../net/drivers/experimental/e1000/e1000_main.c    |    3 +-
 kernel/drivers/net/drivers/fec.c                   |    3 +-
 kernel/drivers/net/drivers/macb.c                  |    2 +-
 .../drivers/net/drivers/mpc52xx_fec/mpc52xx_fec.c  |    2 +-
 kernel/drivers/net/drivers/mpc8260_fcc_enet.c      |    2 +-
 kernel/drivers/net/drivers/mpc8xx_enet.c           |    2 +-
 kernel/drivers/net/drivers/mpc8xx_fec.c            |    2 +-
 kernel/drivers/net/drivers/natsemi.c               |    3 +-
 kernel/drivers/net/drivers/pcnet32.c               |    2 +-
 kernel/drivers/net/drivers/r8169.c                 |    3 +-
 kernel/drivers/net/drivers/smc91111.c              |    2 +-
 kernel/drivers/net/drivers/tulip/tulip_core.c      |    3 +-
 kernel/drivers/net/drivers/via-rhine.c             |    3 +-
 kernel/drivers/net/stack/include/rtdev.h           |    4 +--
 kernel/drivers/net/stack/include/rtwlan.h          |    2 +-
 kernel/drivers/net/stack/ipv4/udp/udp.c            |    3 --
 kernel/drivers/net/stack/rtdev.c                   |   34 ++++++++++++--------
 kernel/drivers/net/stack/rtwlan.c                  |    4 +--
 25 files changed, 55 insertions(+), 42 deletions(-)

diff --git a/kernel/drivers/net/drivers/8139too.c 
b/kernel/drivers/net/drivers/8139too.c
index 1e102fb..8b1a7df 100644
--- a/kernel/drivers/net/drivers/8139too.c
+++ b/kernel/drivers/net/drivers/8139too.c
@@ -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;
diff --git a/kernel/drivers/net/drivers/at91_ether.c 
b/kernel/drivers/net/drivers/at91_ether.c
index b9dc2ea..c697978 100644
--- a/kernel/drivers/net/drivers/at91_ether.c
+++ b/kernel/drivers/net/drivers/at91_ether.c
@@ -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;
 
diff --git a/kernel/drivers/net/drivers/e1000/e1000_main.c 
b/kernel/drivers/net/drivers/e1000/e1000_main.c
index 30b3108..51e9a82 100644
--- a/kernel/drivers/net/drivers/e1000/e1000_main.c
+++ b/kernel/drivers/net/drivers/e1000/e1000_main.c
@@ -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;
diff --git a/kernel/drivers/net/drivers/e1000e/netdev.c 
b/kernel/drivers/net/drivers/e1000e/netdev.c
index d83d228..219b978 100644
--- a/kernel/drivers/net/drivers/e1000e/netdev.c
+++ b/kernel/drivers/net/drivers/e1000e/netdev.c
@@ -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;
 
diff --git a/kernel/drivers/net/drivers/eepro100.c 
b/kernel/drivers/net/drivers/eepro100.c
index 03c9aa7..6d54643 100644
--- a/kernel/drivers/net/drivers/eepro100.c
+++ b/kernel/drivers/net/drivers/eepro100.c
@@ -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);
diff --git a/kernel/drivers/net/drivers/eth1394.c 
b/kernel/drivers/net/drivers/eth1394.c
index fffbc70..7c6494e 100644
--- a/kernel/drivers/net/drivers/eth1394.c
+++ b/kernel/drivers/net/drivers/eth1394.c
@@ -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");
diff --git a/kernel/drivers/net/drivers/experimental/3c59x.c 
b/kernel/drivers/net/drivers/experimental/3c59x.c
index 230158b..bae3308 100644
--- a/kernel/drivers/net/drivers/experimental/3c59x.c
+++ b/kernel/drivers/net/drivers/experimental/3c59x.c
@@ -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");
diff --git a/kernel/drivers/net/drivers/experimental/e1000/e1000_main.c 
b/kernel/drivers/net/drivers/experimental/e1000/e1000_main.c
index 0d295d0..546df9c 100644
--- a/kernel/drivers/net/drivers/experimental/e1000/e1000_main.c
+++ b/kernel/drivers/net/drivers/experimental/e1000/e1000_main.c
@@ -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;
diff --git a/kernel/drivers/net/drivers/fec.c b/kernel/drivers/net/drivers/fec.c
index 8577c89..290b765 100644
--- a/kernel/drivers/net/drivers/fec.c
+++ b/kernel/drivers/net/drivers/fec.c
@@ -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;
diff --git a/kernel/drivers/net/drivers/macb.c 
b/kernel/drivers/net/drivers/macb.c
index 04f4c77..91a4346 100644
--- a/kernel/drivers/net/drivers/macb.c
+++ b/kernel/drivers/net/drivers/macb.c
@@ -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;
 
diff --git a/kernel/drivers/net/drivers/mpc52xx_fec/mpc52xx_fec.c 
b/kernel/drivers/net/drivers/mpc52xx_fec/mpc52xx_fec.c
index 29b1d2e..5e8f16d 100644
--- a/kernel/drivers/net/drivers/mpc52xx_fec/mpc52xx_fec.c
+++ b/kernel/drivers/net/drivers/mpc52xx_fec/mpc52xx_fec.c
@@ -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");
diff --git a/kernel/drivers/net/drivers/mpc8260_fcc_enet.c 
b/kernel/drivers/net/drivers/mpc8260_fcc_enet.c
index 2a7f040..ad64407 100644
--- a/kernel/drivers/net/drivers/mpc8260_fcc_enet.c
+++ b/kernel/drivers/net/drivers/mpc8260_fcc_enet.c
@@ -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;
diff --git a/kernel/drivers/net/drivers/mpc8xx_enet.c 
b/kernel/drivers/net/drivers/mpc8xx_enet.c
index b7f84b7..9430532 100644
--- a/kernel/drivers/net/drivers/mpc8xx_enet.c
+++ b/kernel/drivers/net/drivers/mpc8xx_enet.c
@@ -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;
diff --git a/kernel/drivers/net/drivers/mpc8xx_fec.c 
b/kernel/drivers/net/drivers/mpc8xx_fec.c
index abfe477..df31f99 100644
--- a/kernel/drivers/net/drivers/mpc8xx_fec.c
+++ b/kernel/drivers/net/drivers/mpc8xx_fec.c
@@ -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;
diff --git a/kernel/drivers/net/drivers/natsemi.c 
b/kernel/drivers/net/drivers/natsemi.c
index dc894df..e477472 100644
--- a/kernel/drivers/net/drivers/natsemi.c
+++ b/kernel/drivers/net/drivers/natsemi.c
@@ -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;
diff --git a/kernel/drivers/net/drivers/pcnet32.c 
b/kernel/drivers/net/drivers/pcnet32.c
index 765105f..7dfe28f 100644
--- a/kernel/drivers/net/drivers/pcnet32.c
+++ b/kernel/drivers/net/drivers/pcnet32.c
@@ -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");
diff --git a/kernel/drivers/net/drivers/r8169.c 
b/kernel/drivers/net/drivers/r8169.c
index 9c08e10..5da29bd 100644
--- a/kernel/drivers/net/drivers/r8169.c
+++ b/kernel/drivers/net/drivers/r8169.c
@@ -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;
diff --git a/kernel/drivers/net/drivers/smc91111.c 
b/kernel/drivers/net/drivers/smc91111.c
index fd0d17e..f2c32b4 100644
--- a/kernel/drivers/net/drivers/smc91111.c
+++ b/kernel/drivers/net/drivers/smc91111.c
@@ -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;
diff --git a/kernel/drivers/net/drivers/tulip/tulip_core.c 
b/kernel/drivers/net/drivers/tulip/tulip_core.c
index d88aad1..4db55f8 100644
--- a/kernel/drivers/net/drivers/tulip/tulip_core.c
+++ b/kernel/drivers/net/drivers/tulip/tulip_core.c
@@ -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;
diff --git a/kernel/drivers/net/drivers/via-rhine.c 
b/kernel/drivers/net/drivers/via-rhine.c
index 2d51618..b623a89 100644
--- a/kernel/drivers/net/drivers/via-rhine.c
+++ b/kernel/drivers/net/drivers/via-rhine.c
@@ -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;
diff --git a/kernel/drivers/net/stack/include/rtdev.h 
b/kernel/drivers/net/stack/include/rtdev.h
index 5af153f..67a8ffd 100644
--- a/kernel/drivers/net/stack/include/rtdev.h
+++ b/kernel/drivers/net/stack/include/rtdev.h
@@ -116,7 +116,7 @@ struct rtnet_device {
 
     unsigned int        add_rtskbs; /* additionally allocated global rtskbs */
 
-    struct rtskb_pool   rx_pool;
+    struct rtskb_pool   dev_pool;
 
     /* RTmac related fields */
     struct rtmac_disc   *mac_disc;
@@ -175,7 +175,7 @@ extern struct rtnet_device *rtnet_devices[];
 
 
 struct rtnet_device *__rt_alloc_etherdev(unsigned sizeof_priv,
-                                       unsigned rx_pool_size,
+                                       unsigned dev_pool_size,
                                        struct module *module);
 #define rt_alloc_etherdev(priv_size, rx_size) \
     __rt_alloc_etherdev(priv_size, rx_size, THIS_MODULE)
diff --git a/kernel/drivers/net/stack/include/rtwlan.h 
b/kernel/drivers/net/stack/include/rtwlan.h
index 47d816f..2447d82 100644
--- a/kernel/drivers/net/stack/include/rtwlan.h
+++ b/kernel/drivers/net/stack/include/rtwlan.h
@@ -241,7 +241,7 @@ static inline void * rtwlan_priv(struct rtwlan_device 
*rtwlan_dev)
     return (void *)rtwlan_dev + sizeof(struct rtwlan_device);
 }
 
-struct rtnet_device * rtwlan_alloc_dev(unsigned sizeof_priv, unsigned 
rx_pool_size);
+struct rtnet_device * rtwlan_alloc_dev(unsigned sizeof_priv, unsigned 
dev_pool_size);
 int rtwlan_rx(struct rtskb * rtskb, struct rtnet_device * rtnet_dev);
 int rtwlan_tx(struct rtskb * rtskb, struct rtnet_device * rtnet_dev);
 
diff --git a/kernel/drivers/net/stack/ipv4/udp/udp.c 
b/kernel/drivers/net/stack/ipv4/udp/udp.c
index e2923d6..3eaca64 100644
--- a/kernel/drivers/net/stack/ipv4/udp/udp.c
+++ b/kernel/drivers/net/stack/ipv4/udp/udp.c
@@ -655,8 +655,6 @@ struct rtsocket *rt_udp_dest_socket(struct rtskb *skb)
     return skb->sk;
 }
 
-
-
 /***
  *  rt_udp_rcv
  */
@@ -667,7 +665,6 @@ void rt_udp_rcv (struct rtskb *skb)
     void            *callback_arg;
     rtdm_lockctx_t  context;
 
-
     rtskb_queue_tail(&sock->incoming, skb);
     rtdm_sem_up(&sock->pending_sem);
 
diff --git a/kernel/drivers/net/stack/rtdev.c b/kernel/drivers/net/stack/rtdev.c
index 4bc108f..29d79c6 100644
--- a/kernel/drivers/net/stack/rtdev.c
+++ b/kernel/drivers/net/stack/rtdev.c
@@ -65,7 +65,7 @@ EXPORT_SYMBOL_GPL(rtdev_reference);
 
 struct rtskb *rtnetdev_alloc_rtskb(struct rtnet_device *rtdev, unsigned int 
size)
 {
-    struct rtskb *rtskb = alloc_rtskb(size, &rtdev->rx_pool);
+    struct rtskb *rtskb = alloc_rtskb(size, &rtdev->dev_pool);
     if (rtskb)
        rtskb->rtdev = rtdev;
     return rtskb;
@@ -235,19 +235,19 @@ void rtdev_alloc_name(struct rtnet_device *rtdev, const 
char *mask)
     }
 }
 
-static int rtdev_rx_pool_trylock(void *cookie)
+static int rtdev_pool_trylock(void *cookie)
 {
     return rtdev_reference(cookie);
 }
 
-static void rtdev_rx_pool_unlock(void *cookie)
+static void rtdev_pool_unlock(void *cookie)
 {
     rtdev_dereference(cookie);
 }
 
 static const struct rtskb_pool_lock_ops rtdev_ops = {
-    .trylock = rtdev_rx_pool_trylock,
-    .unlock = rtdev_rx_pool_unlock,
+    .trylock = rtdev_pool_trylock,
+    .unlock = rtdev_pool_unlock,
 };
 
 /***
@@ -256,7 +256,7 @@ static const struct rtskb_pool_lock_ops rtdev_ops = {
  *
  *  allocate memory for a new rt-network-adapter
  */
-struct rtnet_device *rtdev_alloc(unsigned sizeof_priv, unsigned rx_pool_size)
+struct rtnet_device *rtdev_alloc(unsigned sizeof_priv, unsigned dev_pool_size)
 {
     struct rtnet_device *rtdev;
     unsigned            alloc_size;
@@ -274,10 +274,10 @@ struct rtnet_device *rtdev_alloc(unsigned sizeof_priv, 
unsigned rx_pool_size)
 
     memset(rtdev, 0, alloc_size);
 
-    ret = rtskb_pool_init(&rtdev->rx_pool, rx_pool_size, &rtdev_ops, rtdev);
-    if (ret < rx_pool_size) {
-       printk(KERN_ERR "RTnet: cannot allocate rtnet device RX pool\n");
-       rtskb_pool_release(&rtdev->rx_pool);
+    ret = rtskb_pool_init(&rtdev->dev_pool, dev_pool_size, &rtdev_ops, rtdev);
+    if (ret < dev_pool_size) {
+       printk(KERN_ERR "RTnet: cannot allocate rtnet device pool\n");
+       rtskb_pool_release(&rtdev->dev_pool);
        kfree(rtdev);
        return NULL;
     }
@@ -305,7 +305,7 @@ struct rtnet_device *rtdev_alloc(unsigned sizeof_priv, 
unsigned rx_pool_size)
 void rtdev_free (struct rtnet_device *rtdev)
 {
     if (rtdev != NULL) {
-       rtskb_pool_release(&rtdev->rx_pool);
+       rtskb_pool_release(&rtdev->dev_pool);
        rtskb_pool_shrink(&global_pool, rtdev->add_rtskbs);
        rtdev->stack_event = NULL;
        rtdm_mutex_destroy(&rtdev->xmit_mutex);
@@ -319,7 +319,7 @@ void rtdev_free (struct rtnet_device *rtdev)
  * rtalloc_etherdev - Allocates and sets up an ethernet device
  * @sizeof_priv: size of additional driver-private structure to
  *               be allocated for this ethernet device
- * @rx_pool_size: size of the rx pool
+ * @dev_pool_size: size of the rx pool
  * @module: module creating the deivce
  *
  * Fill in the fields of the device structure with ethernet-generic
@@ -328,12 +328,12 @@ void rtdev_free (struct rtnet_device *rtdev)
  * A 32-byte alignment is enforced for the private data area.
  */
 struct rtnet_device *__rt_alloc_etherdev(unsigned sizeof_priv,
-                                       unsigned rx_pool_size,
+                                       unsigned dev_pool_size,
                                        struct module *module)
 {
     struct rtnet_device *rtdev;
 
-    rtdev = rtdev_alloc(sizeof_priv, rx_pool_size);
+    rtdev = rtdev_alloc(sizeof_priv, dev_pool_size);
     if (!rtdev)
        return NULL;
 
@@ -705,6 +705,12 @@ int rtdev_xmit(struct rtskb *rtskb)
 
     rtdev = rtskb->rtdev;
 
+    if (rtskb_acquire(rtskb, &rtdev->dev_pool) != 0) {
+       err = -ENOBUFS;
+       kfree_rtskb(rtskb);
+       return err;
+    }
+
     RTNET_ASSERT(rtdev != NULL, return -EINVAL;);
 
     err = rtdev->start_xmit(rtskb, rtdev);
diff --git a/kernel/drivers/net/stack/rtwlan.c 
b/kernel/drivers/net/stack/rtwlan.c
index bbe4280..2eb8ea1 100644
--- a/kernel/drivers/net/stack/rtwlan.c
+++ b/kernel/drivers/net/stack/rtwlan.c
@@ -95,14 +95,14 @@ EXPORT_SYMBOL_GPL(rtwlan_tx);
  * A 32-byte alignment is enforced for the private data area.
  */
 
-struct rtnet_device *rtwlan_alloc_dev(unsigned sizeof_priv, unsigned 
rx_pool_size)
+struct rtnet_device *rtwlan_alloc_dev(unsigned sizeof_priv, unsigned 
dev_pool_size)
 {
     struct rtnet_device *rtnet_dev;
 
     RTWLAN_DEBUG("Start.\n");
 
     rtnet_dev = rt_alloc_etherdev(sizeof(struct rtwlan_device) + sizeof_priv,
-                           rx_pool_size);
+                           dev_pool_size);
     if (!rtnet_dev)
        return NULL;
 


_______________________________________________
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://xenomai.org/mailman/listinfo/xenomai-git

Reply via email to