aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/firewire
diff options
context:
space:
mode:
authorStefan Richter <stefanr@s5r6.in-berlin.de>2010-11-06 11:57:28 -0400
committerStefan Richter <stefanr@s5r6.in-berlin.de>2010-11-16 18:08:48 -0500
commit7ee11fa8d0a84b05cefe12b0bebc05ab0ea89cd6 (patch)
treeed0f67e8b3687aef93acd50db1f635d43c8073f5 /drivers/firewire
parent902bca00dc6e3b3ff5fbb1e32e5dbb45d5f30579 (diff)
firewire: net: fix memory leaks
a) fwnet_transmit_packet_done used to poison ptask->pt_link by list_del. If fwnet_send_packet checked later whether it was responsible to clean up (in the border case that the TX soft IRQ was outpaced by the AT-req tasklet on another CPU), it missed this because ptask->pt_link was no longer shown as empty. b) If fwnet_write_complete got an rcode other than RCODE_COMPLETE, we missed to free the skb and ptask entirely. Also, count stats.tx_dropped and stats.tx_errors when rcode != 0. Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Diffstat (limited to 'drivers/firewire')
-rw-r--r--drivers/firewire/net.c35
1 files changed, 31 insertions, 4 deletions
diff --git a/drivers/firewire/net.c b/drivers/firewire/net.c
index e2e968e732bc..3a27cee5bf26 100644
--- a/drivers/firewire/net.c
+++ b/drivers/firewire/net.c
@@ -916,9 +916,10 @@ static void fwnet_transmit_packet_done(struct fwnet_packet_task *ptask)
916 916
917 /* Check whether we or the networking TX soft-IRQ is last user. */ 917 /* Check whether we or the networking TX soft-IRQ is last user. */
918 free = (ptask->outstanding_pkts == 0 && !list_empty(&ptask->pt_link)); 918 free = (ptask->outstanding_pkts == 0 && !list_empty(&ptask->pt_link));
919 if (free)
920 list_del(&ptask->pt_link);
919 921
920 if (ptask->outstanding_pkts == 0) { 922 if (ptask->outstanding_pkts == 0) {
921 list_del(&ptask->pt_link);
922 dev->netdev->stats.tx_packets++; 923 dev->netdev->stats.tx_packets++;
923 dev->netdev->stats.tx_bytes += skb->len; 924 dev->netdev->stats.tx_bytes += skb->len;
924 } 925 }
@@ -973,6 +974,31 @@ static void fwnet_transmit_packet_done(struct fwnet_packet_task *ptask)
973 fwnet_free_ptask(ptask); 974 fwnet_free_ptask(ptask);
974} 975}
975 976
977static void fwnet_transmit_packet_failed(struct fwnet_packet_task *ptask)
978{
979 struct fwnet_device *dev = ptask->dev;
980 unsigned long flags;
981 bool free;
982
983 spin_lock_irqsave(&dev->lock, flags);
984
985 /* One fragment failed; don't try to send remaining fragments. */
986 ptask->outstanding_pkts = 0;
987
988 /* Check whether we or the networking TX soft-IRQ is last user. */
989 free = !list_empty(&ptask->pt_link);
990 if (free)
991 list_del(&ptask->pt_link);
992
993 dev->netdev->stats.tx_dropped++;
994 dev->netdev->stats.tx_errors++;
995
996 spin_unlock_irqrestore(&dev->lock, flags);
997
998 if (free)
999 fwnet_free_ptask(ptask);
1000}
1001
976static void fwnet_write_complete(struct fw_card *card, int rcode, 1002static void fwnet_write_complete(struct fw_card *card, int rcode,
977 void *payload, size_t length, void *data) 1003 void *payload, size_t length, void *data)
978{ 1004{
@@ -980,11 +1006,12 @@ static void fwnet_write_complete(struct fw_card *card, int rcode,
980 1006
981 ptask = data; 1007 ptask = data;
982 1008
983 if (rcode == RCODE_COMPLETE) 1009 if (rcode == RCODE_COMPLETE) {
984 fwnet_transmit_packet_done(ptask); 1010 fwnet_transmit_packet_done(ptask);
985 else 1011 } else {
986 fw_error("fwnet_write_complete: failed: %x\n", rcode); 1012 fw_error("fwnet_write_complete: failed: %x\n", rcode);
987 /* ??? error recovery */ 1013 fwnet_transmit_packet_failed(ptask);
1014 }
988} 1015}
989 1016
990static int fwnet_send_packet(struct fwnet_packet_task *ptask) 1017static int fwnet_send_packet(struct fwnet_packet_task *ptask)