Skip to content

Commit

Permalink
skge: fix invalid value passed to pci_unmap_sigle
Browse files Browse the repository at this point in the history
In my patch c194992 ("skge: fix
broken driver") I didn't fix the skge bug correctly. The value of the
new mapping (not old) was passed to pci_unmap_single.

If we enable CONFIG_DMA_API_DEBUG, it results in this warning:
WARNING: CPU: 0 PID: 0 at lib/dma-debug.c:986 check_sync+0x4c4/0x580()
skge 0000:02:07.0: DMA-API: device driver tries to sync DMA memory it has
not allocated [device address=0x000000023a0096c0] [size=1536 bytes]

This patch makes the skge driver pass the correct value to
pci_unmap_single and fixes the warning. It copies the old descriptor to
on-stack variable "ee" and unmaps it if mapping of the new descriptor
succeeded.

This patch should be backported to 3.11-stable.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Reported-by: Francois Romieu <romieu@fr.zoreil.com>
Tested-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Mikulas Patocka authored and David S. Miller committed Sep 24, 2013
1 parent 8d65b11 commit 3361dc9
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions drivers/net/ethernet/marvell/skge.c
Original file line number Diff line number Diff line change
Expand Up @@ -3086,13 +3086,16 @@ static struct sk_buff *skge_rx_get(struct net_device *dev,
PCI_DMA_FROMDEVICE);
skge_rx_reuse(e, skge->rx_buf_size);
} else {
struct skge_element ee;
struct sk_buff *nskb;

nskb = netdev_alloc_skb_ip_align(dev, skge->rx_buf_size);
if (!nskb)
goto resubmit;

skb = e->skb;
ee = *e;

skb = ee.skb;
prefetch(skb->data);

if (skge_rx_setup(skge, e, nskb, skge->rx_buf_size) < 0) {
Expand All @@ -3101,8 +3104,8 @@ static struct sk_buff *skge_rx_get(struct net_device *dev,
}

pci_unmap_single(skge->hw->pdev,
dma_unmap_addr(e, mapaddr),
dma_unmap_len(e, maplen),
dma_unmap_addr(&ee, mapaddr),
dma_unmap_len(&ee, maplen),
PCI_DMA_FROMDEVICE);
}

Expand Down

0 comments on commit 3361dc9

Please sign in to comment.