Skip to contentSkip to conversation

forcedeth: Fix incorrect parameters in pci_unmap_single calls

PATCH New Manfred Spraul 1 participant 1 message Dec 22, 2005

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 forcedeth: Fix incorrect parameters in pci_unmap_single calls

Hi,

The natsemi rx codepath calls pci_unmap_single with a different size than the initial pci_map_single call. The attached patch fixes that.

drivers/net/natsemi.c +5 -2
@@ -1920,6 +1920,7 @@
 		int entry = np->dirty_rx % RX_RING_SIZE;
 		if (np->rx_skbuff[entry] == NULL) {
 			unsigned int buflen = np->rx_buf_sz+NATSEMI_PADDING;
+
 			skb = dev_alloc_skb(buflen);
 			np->rx_skbuff[entry] = skb;
 			if (skb == NULL)
@@ -2006,7 +2007,6 @@
 static void drain_rx(struct net_device *dev)
 {
 	struct netdev_private *np = netdev_priv(dev);
-	unsigned int buflen = np->rx_buf_sz;
 	int i;
 
 	/* Free all the skbuffs in the Rx queue. */
@@ -2014,6 +2014,8 @@
 		np->rx_ring[i].cmd_status = 0;
 		np->rx_ring[i].addr = 0xBADF00D0; /* An invalid address. */
 		if (np->rx_skbuff[i]) {
+			unsigned int buflen = np->rx_buf_sz+NATSEMI_PADDING;
+
 			pci_unmap_single(np->pci_dev,
 				np->rx_dma[i], buflen,
 				PCI_DMA_FROMDEVICE);
@@ -2225,7 +2227,6 @@
 	int entry = np->cur_rx % RX_RING_SIZE;
 	int boguscnt = np->dirty_rx + RX_RING_SIZE - np->cur_rx;
 	s32 desc_status = le32_to_cpu(np->rx_head_desc->cmd_status);
-	unsigned int buflen = np->rx_buf_sz;
 	void __iomem * ioaddr = ns_ioaddr(dev);
 
 	/* If the driver owns the next entry it's a new packet. Send it up. */
@@ -2267,6 +2268,8 @@
 			 */
 		} else {
 			struct sk_buff *skb;
+			unsigned int buflen = np->rx_buf_sz+NATSEMI_PADDING;
+
 			/* Omit CRC size. */
 			/* Check if the packet is long enough to accept
 			 * without copying to a minimally-sized skbuff. */