diff options
author | kirjanov@gmail.com <kirjanov@gmail.com> | 2010-02-24 03:41:18 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-02-26 05:08:47 -0500 |
commit | e382c3018ad19744d3c5d281daf4b0e9f052af66 (patch) | |
tree | 3753477e8559874b2791a97d0fa008ab1098d55d /drivers/net/sis190.c | |
parent | dee7399c2d9a1d3b0af5d68d7e0dd922e104a2a8 (diff) |
sis190: handle DMA mapping errors
Signed-off-by: Denis Kirjanov <kirjanov@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/sis190.c')
-rw-r--r-- | drivers/net/sis190.c | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/drivers/net/sis190.c b/drivers/net/sis190.c index 4487b065ef72..80af4a44580e 100644 --- a/drivers/net/sis190.c +++ b/drivers/net/sis190.c | |||
@@ -484,18 +484,24 @@ static struct sk_buff *sis190_alloc_rx_skb(struct sis190_private *tp, | |||
484 | { | 484 | { |
485 | u32 rx_buf_sz = tp->rx_buf_sz; | 485 | u32 rx_buf_sz = tp->rx_buf_sz; |
486 | struct sk_buff *skb; | 486 | struct sk_buff *skb; |
487 | dma_addr_t mapping; | ||
487 | 488 | ||
488 | skb = netdev_alloc_skb(tp->dev, rx_buf_sz); | 489 | skb = netdev_alloc_skb(tp->dev, rx_buf_sz); |
489 | if (likely(skb)) { | 490 | if (unlikely(!skb)) |
490 | dma_addr_t mapping; | 491 | goto skb_alloc_failed; |
491 | 492 | mapping = pci_map_single(tp->pci_dev, skb->data, tp->rx_buf_sz, | |
492 | mapping = pci_map_single(tp->pci_dev, skb->data, tp->rx_buf_sz, | 493 | PCI_DMA_FROMDEVICE); |
493 | PCI_DMA_FROMDEVICE); | 494 | if (pci_dma_mapping_error(tp->pci_dev, mapping)) |
494 | sis190_map_to_asic(desc, mapping, rx_buf_sz); | 495 | goto out; |
495 | } else | 496 | sis190_map_to_asic(desc, mapping, rx_buf_sz); |
496 | sis190_make_unusable_by_asic(desc); | ||
497 | 497 | ||
498 | return skb; | 498 | return skb; |
499 | |||
500 | out: | ||
501 | dev_kfree_skb_any(skb); | ||
502 | skb_alloc_failed: | ||
503 | sis190_make_unusable_by_asic(desc); | ||
504 | return NULL; | ||
499 | } | 505 | } |
500 | 506 | ||
501 | static u32 sis190_rx_fill(struct sis190_private *tp, struct net_device *dev, | 507 | static u32 sis190_rx_fill(struct sis190_private *tp, struct net_device *dev, |
@@ -1184,6 +1190,11 @@ static netdev_tx_t sis190_start_xmit(struct sk_buff *skb, | |||
1184 | } | 1190 | } |
1185 | 1191 | ||
1186 | mapping = pci_map_single(tp->pci_dev, skb->data, len, PCI_DMA_TODEVICE); | 1192 | mapping = pci_map_single(tp->pci_dev, skb->data, len, PCI_DMA_TODEVICE); |
1193 | if (pci_dma_mapping_error(tp->pci_dev, mapping)) { | ||
1194 | netif_err(tp, tx_err, dev, | ||
1195 | "PCI mapping failed, dropping packet"); | ||
1196 | return NETDEV_TX_BUSY; | ||
1197 | } | ||
1187 | 1198 | ||
1188 | tp->Tx_skbuff[entry] = skb; | 1199 | tp->Tx_skbuff[entry] = skb; |
1189 | 1200 | ||