patch-2.2.2 linux/drivers/net/tlan.c
Next file: linux/drivers/net/z85230.c
Previous file: linux/drivers/net/syncppp.h
Back to the patch index
Back to the overall index
- Lines: 62
- Date:
Sat Feb 6 12:46:21 1999
- Orig file:
v2.2.1/linux/drivers/net/tlan.c
- Orig date:
Fri Jan 8 22:36:08 1999
diff -u --recursive --new-file v2.2.1/linux/drivers/net/tlan.c linux/drivers/net/tlan.c
@@ -29,6 +29,8 @@
*
* Tigran Aivazian <tigran@sco.com>: TLan_PciProbe() now uses
* new PCI BIOS interface.
+ * Alan Cox <alan@redhat.com>: Fixed the out of memory
+ * handling.
*
********************************************************************/
@@ -1250,28 +1252,36 @@
netif_rx( skb );
}
} else {
- skb = (struct sk_buff *) head_list->buffer[9].address;
- head_list->buffer[9].address = 0;
- skb_trim( skb, head_list->frameSize );
-
+ struct sk_buff *new_skb;
+
+ /*
+ * I changed the algorithm here. What we now do
+ * is allocate the new frame. If this fails we
+ * simply recycle the frame.
+ */
+
+ new_skb = dev_alloc_skb( TLAN_MAX_FRAME_SIZE + 7 );
+ if ( new_skb != NULL ) {
+ /* If this ever happened it would be a problem */
+ /* not any more - ac */
+ skb = (struct sk_buff *) head_list->buffer[9].address;
+ head_list->buffer[9].address = 0;
+ skb_trim( skb, head_list->frameSize );
#if LINUX_KERNEL_VERSION > 0x20100
priv->stats->rx_bytes += head_list->frameSize;
#endif
- skb->protocol = eth_type_trans( skb, dev );
- netif_rx( skb );
-
- skb = dev_alloc_skb( TLAN_MAX_FRAME_SIZE + 7 );
- if ( skb == NULL ) {
- printk( "TLAN: Couldn't allocate memory for received data.\n" );
- /* If this ever happened it would be a problem */
- } else {
- skb->dev = dev;
- skb_reserve( skb, 2 );
- t = (void *) skb_put( skb, TLAN_MAX_FRAME_SIZE );
+ skb->protocol = eth_type_trans( skb, dev );
+ netif_rx( skb );
+
+ new_skb->dev = dev;
+ skb_reserve( new_skb, 2 );
+ t = (void *) skb_put( new_skb, TLAN_MAX_FRAME_SIZE );
head_list->buffer[0].address = virt_to_bus( t );
- head_list->buffer[9].address = (u32) skb;
+ head_list->buffer[9].address = (u32) new_skb;
}
+ else
+ printk(KERN_WARNING "TLAN: Couldn't allocate memory for received data.\n" );
}
head_list->forward = 0;
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)