[Click] Memory leak in WifiDefrag

Lorenzo Bianconi lorenzo.bianconi83 at gmail.com
Tue Jan 11 08:46:08 EST 2011


Hi all,

I noticed a possible memory leak in the WifiDefrag element. In
particular, this issue is due to the reception of the first fragment
of a different frame from the current reassembled one. In this
condition the new fragment is stored in the PacketInfoTable hashmap
but the older reassembled frame is never deallocated. I wrote this
simple patch in order to fix the issue.

--- a/elements/wifi/wifidefrag.cc
+++ b/elements/wifi/wifidefrag.cc
@@ -74,8 +74,8 @@
     return p;
   }

-  if (frag && (!nfo || nfo->next_frag != frag ||
-	       (nfo->seq && nfo->seq != seq))) {
+  if (!nfo || nfo->next_frag != frag ||
+    (nfo->seq && nfo->seq != seq)) {
     /* unrelated fragment */
     if (_debug) {
       click_chatter("%{element}: unrelated frag %s seq %d frag %d\n",
@@ -83,7 +83,7 @@
 		    src.unparse().c_str(),
 		    seq,
 		    frag);
-      if (nfo) {
+      if (_debug && nfo) {
 	click_chatter("nfo seq %d next_frag %d\n",
 		      nfo->seq,
 		      nfo->next_frag);
@@ -92,8 +92,10 @@
     if (nfo) {
       nfo->clear();
     }
-    p->kill();
-    return 0;
+    if (frag) {
+      p->kill();
+      return 0;
+    }
   }

   if (!nfo) {



Best regards

Lorenzo


More information about the click mailing list