Skip to contentSkip to conversation

fix airo memory leak

PATCH New Daniel Ritz 1 participant 1 message Aug 2, 2003

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix airo memory leak

fixes a memory leak: memory for the airo_devices list is allocated but never freed.

against 2.6.0-test2-bk, but should apply to 2.4 as well...

drivers/net/wireless/airo.c +17 -6
@@ -4038,12 +4038,23 @@
 	return 0;
 }
 
-static void del_airo_dev( struct net_device *dev ) {
-	struct net_device_list **p = &airo_devices;
-	while( *p && ( (*p)->dev != dev ) )
-		p = &(*p)->next;
-	if ( *p && (*p)->dev == dev )
-		*p = (*p)->next;
+static void del_airo_dev(struct net_device *dev)
+{
+	struct net_device_list *this = airo_devices, *prev = NULL;
+
+	while (this) {
+		if (this->dev == dev) {
+			if (prev)
+				prev->next = this->next;
+			else
+				airo_devices = this->next;
+			kfree(this);
+			break;	
+		}
+
+		prev = this;
+		this = this->next;
+	}
 }
 
 #ifdef CONFIG_PCI