diff options
author | Linas Vepstas <linas@austin.ibm.com> | 2006-12-13 16:15:15 -0500 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2007-02-05 16:58:44 -0500 |
commit | 05b346b552e13cc090ea908e2be183b377ff30a2 (patch) | |
tree | 2ff85c154bc808f6567f014e0b57df9bf0591e37 /drivers/net | |
parent | 1cd173f66c392ede57fa10f614fca22d79501424 (diff) |
Spidernet RX skb mem leak
One of the unlikely error branches has an skb memory leak.
Fix this by handling the error conditions consistently.
Signed-off-by: Linas Vepstas <linas@austin.ibm.com>
Cc: James K Lewis <jklewis@us.ibm.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/spider_net.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/drivers/net/spider_net.c b/drivers/net/spider_net.c index f97251a9c850..f1cd13fbd5c1 100644 --- a/drivers/net/spider_net.c +++ b/drivers/net/spider_net.c | |||
@@ -913,8 +913,8 @@ spider_net_do_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd) | |||
913 | * | 913 | * |
914 | * returns 1 on success, 0 if no packet was passed to the stack | 914 | * returns 1 on success, 0 if no packet was passed to the stack |
915 | * | 915 | * |
916 | * iommu-unmaps the skb, fills out skb structure and passes the data to the | 916 | * Fills out skb structure and passes the data to the stack. |
917 | * stack. The descriptor state is not changed. | 917 | * The descriptor state is not changed. |
918 | */ | 918 | */ |
919 | static int | 919 | static int |
920 | spider_net_pass_skb_up(struct spider_net_descr *descr, | 920 | spider_net_pass_skb_up(struct spider_net_descr *descr, |
@@ -929,10 +929,6 @@ spider_net_pass_skb_up(struct spider_net_descr *descr, | |||
929 | 929 | ||
930 | netdev = card->netdev; | 930 | netdev = card->netdev; |
931 | 931 | ||
932 | /* unmap descriptor */ | ||
933 | pci_unmap_single(card->pdev, descr->buf_addr, SPIDER_NET_MAX_FRAME, | ||
934 | PCI_DMA_FROMDEVICE); | ||
935 | |||
936 | /* the cases we'll throw away the packet immediately */ | 932 | /* the cases we'll throw away the packet immediately */ |
937 | if (data_error & SPIDER_NET_DESTROY_RX_FLAGS) { | 933 | if (data_error & SPIDER_NET_DESTROY_RX_FLAGS) { |
938 | if (netif_msg_rx_err(card)) | 934 | if (netif_msg_rx_err(card)) |
@@ -1015,6 +1011,11 @@ spider_net_decode_one_descr(struct spider_net_card *card) | |||
1015 | chain->tail = descr->next; | 1011 | chain->tail = descr->next; |
1016 | 1012 | ||
1017 | result = 0; | 1013 | result = 0; |
1014 | |||
1015 | /* unmap descriptor */ | ||
1016 | pci_unmap_single(card->pdev, descr->buf_addr, | ||
1017 | SPIDER_NET_MAX_FRAME, PCI_DMA_FROMDEVICE); | ||
1018 | |||
1018 | if ( (status == SPIDER_NET_DESCR_RESPONSE_ERROR) || | 1019 | if ( (status == SPIDER_NET_DESCR_RESPONSE_ERROR) || |
1019 | (status == SPIDER_NET_DESCR_PROTECTION_ERROR) || | 1020 | (status == SPIDER_NET_DESCR_PROTECTION_ERROR) || |
1020 | (status == SPIDER_NET_DESCR_FORCE_END) ) { | 1021 | (status == SPIDER_NET_DESCR_FORCE_END) ) { |
@@ -1022,8 +1023,6 @@ spider_net_decode_one_descr(struct spider_net_card *card) | |||
1022 | pr_err("%s: dropping RX descriptor with state %d\n", | 1023 | pr_err("%s: dropping RX descriptor with state %d\n", |
1023 | card->netdev->name, status); | 1024 | card->netdev->name, status); |
1024 | card->netdev_stats.rx_dropped++; | 1025 | card->netdev_stats.rx_dropped++; |
1025 | pci_unmap_single(card->pdev, descr->buf_addr, | ||
1026 | SPIDER_NET_MAX_FRAME, PCI_DMA_FROMDEVICE); | ||
1027 | dev_kfree_skb_irq(descr->skb); | 1026 | dev_kfree_skb_irq(descr->skb); |
1028 | goto refill; | 1027 | goto refill; |
1029 | } | 1028 | } |
@@ -1031,9 +1030,10 @@ spider_net_decode_one_descr(struct spider_net_card *card) | |||
1031 | if ( (status != SPIDER_NET_DESCR_COMPLETE) && | 1030 | if ( (status != SPIDER_NET_DESCR_COMPLETE) && |
1032 | (status != SPIDER_NET_DESCR_FRAME_END) ) { | 1031 | (status != SPIDER_NET_DESCR_FRAME_END) ) { |
1033 | if (netif_msg_rx_err(card)) | 1032 | if (netif_msg_rx_err(card)) |
1034 | pr_err("%s: RX descriptor with state %d\n", | 1033 | pr_err("%s: RX descriptor with unkown state %d\n", |
1035 | card->netdev->name, status); | 1034 | card->netdev->name, status); |
1036 | card->spider_stats.rx_desc_unk_state++; | 1035 | card->spider_stats.rx_desc_unk_state++; |
1036 | dev_kfree_skb_irq(descr->skb); | ||
1037 | goto refill; | 1037 | goto refill; |
1038 | } | 1038 | } |
1039 | 1039 | ||